How to set a custom header on QML NetworkRequest Type?

645
2
Jump to solution
02-20-2019 09:18 AM
MattEnglish
Esri Contributor

Hi:

I need to set "Content-Type" to  "application/json;charset=UTF-8" for a POST request to a 3rd party API.

How do I do this. It's not clear in the API doc.

cheers

Matt

0 Kudos
1 Solution

Accepted Solutions
ErwinSoekianto
Esri Regular Contributor

Matt, 

If you are using the NetworkRequest from AppStudio AppFramework, then you can set it like this, 

networkRequest.headers["Content-Type"] = "application/json;charset=UTF-8";

This is documented on this API-Guide link (scroll all the way to the bottom), Work with networking services—AppStudio for ArcGIS | ArcGIS 

Thank you,

Erwin. 

View solution in original post

0 Kudos
2 Replies
ErwinSoekianto
Esri Regular Contributor

Matt, 

If you are using the NetworkRequest from AppStudio AppFramework, then you can set it like this, 

networkRequest.headers["Content-Type"] = "application/json;charset=UTF-8";

This is documented on this API-Guide link (scroll all the way to the bottom), Work with networking services—AppStudio for ArcGIS | ArcGIS 

Thank you,

Erwin. 

0 Kudos
MattEnglish
Esri Contributor

It would be helpful to have this info here as well:

NetworkRequestHeaders QML Type

0 Kudos