Request Headers

Hello! We're trying to make API calls to the website we're using ( and it requires a header for the api key. How would I do this in Kinoma? I've made API calls without using headers before, but not sure how to invoke the handler when it requires a header. For reference, this is what the call looks like in terminal: curl -G -H "api_key: YOUR_API_KEY" --data-urlencode 'q={"search":"apple iphone"}'


  • Hello! You can add any custom header you need with the setRequestHeader(string, string) method of the Message object. It just takes simple key-value pairs. The code snippet below should get you on your way.

    var url = "";
    var msg = new Message(url + serializeQuery({search:"apple iphone"}));   
    msg.setRequestHeader("api_key", "YOUR_API_KEY");
    msg.method = "GET";



  • Hi Will, 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.01/abc data to be sent : {lmn: 'rock'} method: POST

    What will be the code for this example?

    Thank you

Sign In or Register to comment.