Setting the header values in webRequest?
So can anyone tell me how I set/amend the header name/value pairs in the WebRequest activity?
Basically I have a workflow which generates a JSON string; this utlimately needs to be passed to an external REST web service (POST method) which accepts JSON in the message payload (Content-Type:application/json).
So in my workflow I have:
1) Converted my JSON string to byte data with (getBytesFromText with UTF8 encoding) - variable named 'outputRequestByte')
2) In my webRequest activity I have then set the then set 'Raw Data' to this 'outputRequestByte' variable, assigned the URI endpoint.; and explicitly set the method to POST
However in the webRequest I think I also need to explcitly set the Content-Type header name to a value of "application/json", but whilst I have no problem setting the webRequest Header parameter to a variable of System.Net.WebHeaderCollection I am struggling to assign a name/value pair of "Content-Type:application/json" to this collection variable.
Can anyone help? A similar thread (in whihc I've also posted my problem) called setting Content-Type of WebRequest states this is entirely possible - but unfortiunately the referenced workflows in this thread are not accessible. Sure I'm doing something silly here......
Thanks
0
-
Hi Phil,
You need to create a variable say "webHeaders" of type "System.Net.WebHeaderCollection", then use an Invoke Method as follows:
TargetObject = webHeaders
MethodName = Add
Parameters: Type = String
Value = "new WebHeaders("Accept: application/json; odata=verbose") Now, pass webHeader to the WebRequest activity as headers.
Kindly let me know if you need any more help.
Regards,
Mohammad Ashraf0 -
Trying to do this but get the error: "
The Content-Type header cannot be changed from its default value for this request."0 -
Hi Darko,
If you are still getting this error, can you please post a sample request and obscure the data as required?
Regards,
Wayne Richard
Latitude Geographics Group Ltd.
Head Office: 300 – 1117 Wharf Street Victoria, BC Canada V8W 1T7
Tel: (250) 381-8130 | Fax: (250) 381-8132 | wrichard@latitudegeo.com
Developers of Geocortex web-based mapping software | www.geocortex.com
An Esri Platinum Business Partner0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
3 kommentarer