publisher button in AngularJS - InvalidDataError

sandeep edited February 2017 in Kite Publisher
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=""

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.
  • sandeep
    Can someone respond please?
  • sujith
    sujith edited February 2017
    Instead of going angular way, try hard coding tradingsymbol and quantity.
    I think, error is because of tradingsymbol.
  • sandeep
    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.
  • sujith
    I think your variable selectedRecord.symbol doesn't contain valid tradingsymbol.
  • sandeep
    sandeep edited February 2017
    tradingsymbol is getting generated. Here is what I see in chrome developer console.

    < a href="" data-kite="my-api-key"

    I have tried this with different symbols and it is the same error everytime.

    Please advise.
  • vishnus
    Hi @sandeep

    The below code works, was just now tested:

    I've used the same trading symbol and quantity like you have given.

  • sandeep
    @vishnus, I have gone thru your code. I guess the issue is w.r.t. the angular environment.

    Please refer the below link where I have simulated the issue.

    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?
  • sandeep
    Hi @vishnus,
    Were you able to simulate the issue at your end? Any suggestions on how to debug this further?
  • vishnus
    @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

  • sandeep

    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.
Sign In or Register to comment.