I am trying to send a single line of text of a employee id in the body of a OkHttp POST request, simulating a request that I see using browser inspection.
The request is a mix of URL params and a single string of employee ID in the body of the post, i.e. ABC123
Currently after login and sending the request the server response is 500.
Request quickFind = new Request.Builder()
.url(quickFIndUrl)
.addHeader("csrf_tok", csrfToken)
.addHeader("x-rest-api", "true")
.addHeader("x-requested-with", "true")
.addHeader("accept-encoding", "gzip, deflate, br")
.addHeader("user-agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Mobile Safari/537.36")
.addHeader("accept", "application/json, text/plain, */*")
.addHeader("origin", "https://contoso.com")
.addHeader("content-type", "application/json;charset=UTF-8")
.post(RequestBody.create(MediaType.parse("text/x-markdown"), postBody))
.build();
What does the line .post(RequestBody.create(MediaType.parse("text/x-markdown"), postBody)
do as I think this might be the cause for server response 500.
On face value it looks the like it sets the MIME type
, but then how is MIME type different to the content-type
above?
What are valid types that can be parsed other than text/x-markdown?
Aucun commentaire:
Enregistrer un commentaire