Set headers explicitly?


When making API calls from scripts, is it a good practice to set headers explicitly? If yes then what headers are most appropriate and needed for making calls to DF API? Like for the example below, what headers are necessary?

var options = {
    "CURLOPT_HTTPHEADER": ["Content-type: application/json", "Some-Other-Header: blah"]
result ="", {"name":"test"}, options);

And a small doubt, when I print the result of an API call I see the following text

Why is the content_type set to null? :thinking:


Hi @m_menon,

Its ok and useful in some cases, but, if you create a service inside DF and need to call this service, you dont need to set headers and also dont need use your full URL. Just call like this:

result =“my_service_name”, {“name”:“test”});

The content type in your header, tells what you are sending and not what you will receive. Maybe your “” doesn’t set the content-type, so the content_type is set to null by DF.

hi Anderson,

Alrightey thanks…that clears it up :slight_smile: