How to pass string value as request body to the post method of third party API

So for above POST API call i am facing an issue for content body not able to pass file path weblink as parameter.

   postBody, _ := json.Marshal(map[string]string{      


   requestBody := bytes.NewBuffer(postBody)

`  resp, err := http.Post(("--POST API call--", "application/json", requestBody )

So if requestBody will fetch POST API call then, it should be allow to pass as a parameter with content body.

but its creating issue as below I have attached Postman snap where we can get to know content body is passing as null which should be like value of "www://"

normally POST call having requestBody body like below

 postBody, _ := json.Marshal(map[string]string{
      "Key1":  "Value1",
      "key2": "Value2",

**But in my case as below ** whichever file path I am calling that pass as a default web url value without key

 postBody, _ := json.Marshal(map[string]string{
       "www://",--------> // here no key available, only value as a string value

I’m wondering why that works for you at all! The given value is not a map!

If you want to send just a string, send just a string, but not a map…

Like NobbZ said: If you don’t want a map[string]string, then just use the string:

 postBody, _ := json.Marshal("www://")

Is it supposed to even be a JSON string (surrounded by double-quotes: "www://") or should it just be a string (without quotes and any escaping)?

postBody := []byte("www://")

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