Empty keys in body are not sent to API

Hi,
i have an issue with my go code. i am calling an api and the body sometimes has only key and no value content-type is application/x-www-form-urlencoded
go seems to not be sending the empty keys and the api call fails :frowning:
req, _ := http.NewRequest(“POST”, jmb_gid_url,strings.NewReader(r.Form.Encode()))
req.Header.Add(“Authorization”, r.Header.Get(“Authorization”))
req.Header.Add(“Content-Type”, r.Header.Get(“Content-Type”))
thanks in advance :slight_smile:

How do you set r.Form?

if err := r.ParseForm(); err != nil {
// handle error
}

So you accept a application/x-www-form-urlencoded request and forward it? Do you need to work with this Content-Type? Can’t you do REST? And have more control over the things?

I looked briefly at the source code of these methods and I don’t think they discard zero values. Do you log both values of ParseForm and Encode?

issues was fixed turns out the api had a specific value for key like country is US , when i was trying to call it with FR it was failing .
thanks :slight_smile:

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