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

edited February 2016 in Kinoma Coding

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 : 127.0.0.1/abc 
   data to be sent : {lmn: 'rock'}
   method: POST

What will be the code for this example?

Thank you

Answers

  • Answer ✓

    Hi there! Sorry this response is so late--this post got buried somehow. In case anyone needs the answer to this:

    For Kinoma Create, the code would be:

    let request = new Message("127.0.0.1/abc");
    request.method = "POST";
    request.requestText = JSON.stringify( {lmn: 'rock'} ); 
    request.invoke();
    

    For Kinoma Element, the code would be:

    import HTTPClientRequest from "HTTPClient";
    let request = new HTTPClientRequest("127.0.0.1/abc");
    request.method = "POST";
    request.start(JSON.stringify( {lmn: 'rock'} ));
    
  • Thanks for your response! It was a long time back but I was able to figure out the solution.

Sign In or Register to comment.