How to code for HTTP POST request with request data (payload)?

edited February 2016 in Kinoma Studio

Can you please tell me what will be the code for POST request. I want to send some JSON data in the request.

For example:

    url : 
    data to be sent : {lmn: 'rock'}
    method: POST

What will be the code for this example?

Thank you


  • Answer ✓


    You'll want to do something like the following to make a (more detail can be found in the Basic Web Service Request Sample)

        var url = '';
        var message = new Message(url);
        message.method = "POST";
        message.requestText = JSON.stringify({algorithm: "MD5", string: originalText});
        container.invoke(message, Message.TEXT);

    Please let me know if you have any further questions.



  • Hi Will, Thank you for your response. This will definitely help. One more clarification I would like to make. To set the headers, We can use as below:

              message.setRequestHeader("X-abc: pqr");

    is this the correct way of setting headers?

  • Answer ✓


    You're close on that syntax, but what the function requires is two distinct strings as arguments. See the following:

      message.setRequestHeader("X-ApiKey", "8675309");

    You're always welcome to ask questions here. But, as another resource for you, check out the KPR-examples GitHub repo. It contains all the public sample code for KinomsJS (and KinomaXML) and is searchable. Searching for setRequestHeader returns a dozen usage examples.



  • Thank you. This is helpful.

Sign In or Register to comment.