This is a creation in Article, where the information may have evolved or changed.
Want to write a client with go, send a JSON data to the Java server interface,
As a result, the body received by Java is always empty, but the server written by Python is ok
Online Search method
Which: Some of the methods have been tried,
Type requestbody struct {
status String ' JSON: ' status '
Region []string ' JSON: ' Region '
Percent string ' JSON: ' Percent '
task_id string ' JSON: ' task_id '
}
B, err: = json. Marshal (Rbody)
Body: = bytes. Newbuffer ([]byte (b))
(1)
RESP, err: = http. Post (URL, "Application/json", body)
(2)
RESP, err: = http. Post (URL, "application/x-www-form-urlencoded", body)
(3)
Client: = &http. client{}
Req, _: = http. Newrequest ("POST", url, body)
Req. Header.set ("Content-type", "Application/json")
RESP, err: = client. Do (req)
Not at all, and finally, try and
Req, _: = http. Newrequest ("POST", url, body)
Switch
Req, _: = http. Newrequest ("POST", URL, strings. Newreader (string (b)))
Okay, OK.