Skip to main content

How to add a default header to a REST callout?

  • 16 October 2018
  • 3 replies
  • 198 views

We are making a REST callout to an external system. We want to default our header in the Service Instance setup and set it to our api key. However, everytime we attempt to run the workflow, we get an error that says "Unable to deserialize value."

 

Here is what we are putting in our default header. How else do you format it? the documantation says its a name/value pair.

 

{”Name”:”Authorization”,”Value”:”Bearer our_key"}

3 replies

Badge +15

Hi,


When you first create a REST service instance, you have to provide a descriptor location. That is the location to your swagger definition. The swagger definition is a json file. You should be able to register your service instance with just that. Ignore the HTTP headers first.


 


After you have created the service instance, expand it, then look under System Types. You should see a service object called 'HttpHeader'. Create a SmartObject from that.


 


Next, execute that HttpHeader SmartObject, and select the Serialize method. Enter the name of the header, follow by the value, and execute the method. You will get a long string. Copy that into a notepad.


 


If you need to add more than one HTTP header, then use the Serialize Item To Array method. Once you execute the method, you will get long string. Copy that. Next, select the Serialize Add Item To Array method, paste the string you have copied into the Serialized Array property, then fill in the next set of header you want to add. Once you execute the method, the new name-value pair will be added into the array. Copy that newly generated string into a notepad.


 


Finally, edit the REST service instance, and paste that string into the Default HTTP Request Headers field. Update your service instance and any future request made to your REST service should include those headers.

Badge +9

HI,

 

You need to set the value while creating the service instance.

 

Check this post to see the step by step process with screen shots

https://vijaydk2guy.wordpress.com/2018/02/08/creating-endpoint-rest-service-instance-for-a-rest-api-which-needs-authorization-bearer-token/

 

Let me know if it works!!

 

Userlevel 3
Badge +5

ViJay,

 

I think you should add a note to your very helpful blog article note, where you talk about "Unable to deserialize" and add a line which says, "If you copy the text above, remember that you need to convert left and right quotes into standard double quote marks."

Reply