How to dynamically set the Authenticate key in the http header of rest Message

Riya25
Giga Contributor

Hello all,

We are implementing an integration using REST Api ,and in that we are having the same end point but different Authentication Keys for different region,so how can we set them dynamically so that it load all the data from 2 regions.

Currently in one method we are generating organization there i have tried to use both the value but its giving me the organization whose key i have mentioned in the Parent Rest Message.

 

find_real_file.png

SO how can i achieve this ?

@Ankur Bawiskar can you please help here?

Help from anyone would be appreciated.

 

Regards,

Riya

10 REPLIES 10

Nikhil Bahurup1
Tera Expert

Hi Riya,

Check point no.7 below.

  1. Navigate to System Web Services > REST Message.
  2. Select a REST message.
  3. (Optional) To specify a header for an HTTP method instead of the REST message, in the HTTP Method related list, select an HTTP method.
  4. Select the HTTP Request tab.
  5. In the HTTP Headers embedded list, click Insert a new row.
  6. Enter the name of the header, such as Content-Type or Accept.
    Supported headers depend on the REST web service provider you want to connect to. Refer to the documentation for your web service provider to identify which headers are valid or required.
  7. Click on the Value field for the new row and enter the value you want to assign this header.
    You can use a variable in the format ${variable} instead of a static value. You can assign a value to the variable when sending a REST request.
  8. Click Update.

Hello Nikhil,

Where we can assign the value to the variable?

Cann you please explain it with an example?

Also i have another method which uses the id returned by the above method to list the devices ,how can i pass those ids dynamically?

I have tries adding in the test values under Variable Substitutions but its not working?

 

Thanks and regards,

Riya

 

You can try something like this.

find_real_file.png

In your script you can pass the required value in Token variable as below.

var r = new sn_ws.RESTMessageV2('your REST message name', 'get'); 
r.setStringParameterNoEscape('Token', 'required value');

Hello Nikhil,

 

I have added this code in the script which is included in the Scheduled JOb.

But when i am testing this method by setting value as ${token},its failing.

 

Also need to ask for the other method which included id in the endpoint :id we are getting through Organization method ,earlier for 1 rganization i have included in varaiable substitution but for 2 organozation should i follow the same process as above?

 

Thank you for the help.

Regards,

Riya