http.NewRequest Unable to Post

Hi Everyone

I am setting up http Post request for a service. I am able to post value using this way : (snippet)

link := “http://localhost:8081/abc/

jsonstring := []byte({"Name": "John", "Age": 29})
resp, _ := http.NewRequest(“POST”, link, bytes.NewBuffer(jsonstring))

but I am unable to post using PostForm or url.Values.
Any feedback what’s wrong here?

What happens? Do you get any error? Which?

I don’t get any error but the values are not getting posted

The small snippet you posted shows you ignoring the error returns. Don’t do that - anywhere. That might show you what’s going on. If not, post your real code and we might be able to assist.

Also, “not getting posted” indicates you are looking at this from the server side as well? If so, check for errors there as well, etc.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.