DEV Community

kundan Jaiswal
kundan Jaiswal

Posted on

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

`postBody, _ := json.Marshal(map[string]string{
"www://xyz.org/file.txt",
})
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://xyz.org/file.txt"

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://xyz.org/file.txt",--------> // here no key available, only value as a string value
})
--------------------------------------------------------------`

Top comments (0)