Httpclient post sends a JSON request, indicating that the parameter is missing, and the request for the form with the same parameter is successful

CSDN Q & A 2022-02-13 06:19:16 阅读数:533

httpclient post sends json request

post Interface send json Method

img

Same interface , Same parameters ,form The way is successful ,json The method prompts that the parameters are incomplete

img

Running results

img

Change to httpPost.addHeader("Content-Type", "application/json"); Not good either.
debug result

img

img




Take the answer :

The other party's service returns you a message , It means you can communicate with each other , The result returned by the other party's service indicates that your request lacks necessary parameters, such as 2 Maybe
1. You send the request with fewer parameters
2. The opposite interface cannot be resolved json Format parameters
Look at the use of... In your problem statement post+form-data The way is to request success , Then I think it may be that the other party's interface cannot receive json Parameters , Please confirm that... Is added to the interface provided by the other party @RequestBody annotation



Other answers 2:

img
The request type of the request header is changed to json Format .

Reference resources :
img

If help , Please accept . Click on the top right corner of my answer 【 Adopt 】 Button .

copyright:author[CSDN Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130619140839.html