Want to send header in business rule - REST API

Jerry121
Kilo Contributor

Hello Everyone,

We are integrating ServiceNow through REST.

1) We are sending our incident number to that tool using rest with post method and we are getting a task number from them in response.

2) I am capturing that task id in a field on incident form.

3) Now, I have another web service where I need to send some fields from same incident form using POST method, here they I want to send these taskid in http header ( ex: content-type - taskid).

4) I am currently trying to trigger using business rule and stuck hear on http header.

Can anyone help me with this???

Thanks,

RK1229

1 ACCEPTED SOLUTION

raghavak
Giga Contributor

Yeah, Arka is right, you can use something like this



r.setRequestHeader("hearder name",current.taskid);



you can use this in your script.



Regards<


Raghava


View solution in original post

6 REPLIES 6

raghavak
Giga Contributor

Hello RK,



If I understand correctly you want to use task id into one of your headers???




Regards,


Raghava


ark6
Mega Guru

Have you tried the setRequestHeader parameter in business rule?



See the Below link. It will help



RESTMessageV2 - setRequestHeader(String name, String value)


Jerry121
Kilo Contributor

ark



Can we send captured task id on the business rule???




RK


Yes you could do that



var a=current.task_id; //field name where you are storing the task id


var sm = new sn_ws.RESTMessageV2("<your rest message name>","<operation>");


sm.setRequestHeader("task_id",a);