I am trying to include Kite Publisher button in AngularJS (1.5.x) environment for my web application. I am getting an error after clicking the button.
Here is what I have done.
Below is the code snippet for the publisher link. < a href="" data-kite="my-api-key" data-exchange="NFO" data-tradingsymbol={{selectedRecord.symbol}} data-transaction_type="BUY" data-quantity={{selectedRecord.lotSize}} data-order_type="MARKET"> Buy
symbol and lotsize are populated dynamically by Angular code. This button is implemented using an Angularjs directive.
After clicking this link, it opens a kite url with the following response { "error_type": "InvalidDataError", "message": "No valid order entries found in the JSON payload", "status": "error" }
Please advise if I have implemented this correctly or if any changes are required. Also guide on how to find out which parameters are not passed correctly.
@sujith, I would not be able to move away from angularjs as that is the platform for my web application. If I hardcode, how do I generate the symbol dynamically? I do not want my application users to always buy the same stock!!
I tried your suggestion and it works because we are left with pure html code and no angularjs elements in it. This does not help me because I need the ability to pass parameters dynamically. Please suggest solution accordingly.
The first button uses html (and it works) and second button uses angularjs (and it does not work).
Also, observed one more thing - this button works if I remove angular-ui-router and work with only angularjs. Unfortunately, that is not the option for me as I am using ui-router for managing states within my application.
@sandeep since its angular specific issue, I wouldn't be able to help in this regard. but we'll keep this thread unclosed to see if any other angular developer in the forum can help you
Let me correct this a bit. It is the issue of publisher.js operating in angular environment. And my issue is I do not know what is happening inside publisher.js. Nor I am able to see the generated payload nor I am able to see which parameter is not getting passed correctly.
Do you have some kind of a debug mode for the publisher.js where we can get some more insight than what is currently available? I am open for a joint debugging session if that can help resolve this issue.
Instead of going angular way, try hard coding tradingsymbol and quantity.
I think, error is because of tradingsymbol.
I would not be able to move away from angularjs as that is the platform for my web application.
If I hardcode, how do I generate the symbol dynamically? I do not want my application users to always buy the same stock!!
I tried your suggestion and it works because we are left with pure html code and no angularjs elements in it. This does not help me because I need the ability to pass parameters dynamically. Please suggest solution accordingly.
I think your variable selectedRecord.symbol doesn't contain valid tradingsymbol.
< a href="" data-kite="my-api-key"
data-exchange="NFO"
data-tradingsymbol="DCBBANK17FEBFUT"
data-transaction_type="BUY"
data-quantity="4500"
data-order_type="MARKET">Buy
I have tried this with different symbols and it is the same error everytime.
Please advise.
The below code works, was just now tested:
https://gist.github.com/vishnus/86d43defc7df2a30064c174e206687ad
I've used the same trading symbol and quantity like you have given.
Please refer the below link where I have simulated the issue.
https://plnkr.co/edit/eoZw5IS2ULq3FlA2vjGN?p=preview
The first button uses html (and it works) and second button uses angularjs (and it does not work).
Also, observed one more thing - this button works if I remove angular-ui-router and work with only angularjs. Unfortunately, that is not the option for me as I am using ui-router for managing states within my application.
Can you take a look at this and advise?
Were you able to simulate the issue at your end? Any suggestions on how to debug this further?
Thanks
Let me correct this a bit. It is the issue of publisher.js operating in angular environment.
And my issue is I do not know what is happening inside publisher.js. Nor I am able to see the generated payload nor I am able to see which parameter is not getting passed correctly.
Do you have some kind of a debug mode for the publisher.js where we can get some more insight than what is currently available?
I am open for a joint debugging session if that can help resolve this issue.
Let me know.