415 unsupported media types
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 08:13 PM
Hello , we are onboarding service now into our tech stack , right now in the process of integrating ServiceNow(SN) with our Java application which calls REST api of SN to create new incidents.
Need the community help in solving this problem ..
the header “content-type’ seem to auto reset on the request header to “application/x-www-form-urlencoded” even though I initially set it to “application/json”. This is making the POST call content empty and a dummy incident is created. I have tried to use a mock http call and compared with postman call. The postman call seem to post using correct header type. I also set a trace on the calls and they seem to show the same .Any insight is greatly appreciated.
NOTE: i did try with other content types too and they seem to have the same problem.
Request Headers from java app
<requestUrl>/invoke/c****sc/mockHTTPserver/ws/ServiceNow_incident/Rome/insert</requestUrl>
<method>POST</method>
<requestHdrs>
<User-Agent>Mozilla/4.0 [en] (WinNT; I)</User-Agent>
<Host>w***555</Host>
<Authorization>Basic a3Z1dHVrdTprdnV0dWt1Mw==</Authorization>
<Content-Type>application/x-www-form-urlencoded</Content-Type>
<Request format>application/json</Request format>
<Response format>application/json</Response format>
<Accept>*/*</Accept>
<Content-Length>21</Content-Length>
</requestHdrs>
Request headers from postman
<method>POST</method>
<requestHdrs>
<Content-Type>application/json</Content-Type>
<Authorization>Basic a3Z1dHVrdTprdnV0dWt1Mw==</Authorization>
<User-Agent>PostmanRuntime/7.29.0</User-Agent>
<Accept>*/*</Accept>
<Cache-Control>no-cache</Cache-Control>
<Postman-Token>7d1dadd6-6dc9-4fee-acc8-fbeb8b68aa4f</Postman-Token>
<Host>wm***55</Host>
<Accept-Encoding>gzip, deflate, br</Accept-Encoding>
<Connection>keep-alive</Connection>
<Content-Length>287</Content-Length>
</requestHdrs>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2022 03:23 AM
have you tried using REST API explorer from ServiceNow, thats the best way to figure out what content type is expected.
https://instancename.service-now.com/$restapi.do