I have a simple function in GAE golang:
func Call(c appengine.Context, guid string, function string, parameters map[string]string) string {
client:=urlfetch.Client(c)
values := url.Values{}
c.Infof("%v", parameters)
for k, v := range parameters {
values.Set(k, v)
}
c.Infof("%v", values)
resp, err:=client.PostForm("https://blockchain.info/merchant/"+guid+"/"+function, values)
var answer string
if err != nil {
c.Errorf("BlockchainAPI post error: %s", err)
}
c.Infof("%v", resp.Request.PostForm)
[...]
I get these printouts:
2013/10/14 23:17:51 INFO: map[main_password:password]
2013/10/14 23:17:51 INFO: map[main_password:[password]]
2013/10/14 23:17:52 INFO: https://blockchain.info/merchant/guid/function
2013/10/14 23:17:52 INFO: map[]
It looks as if client.PostForm
does not pass values
to the request and not get them back in response. What can be causing this error?
`client.PostForm` uses the body not the request.PostForm values.
It says so in the [documentation][1] :
// PostForm contains the parsed form data from POST or PUT
// body parameters.
// This field is only available after ParseForm is called.
// The HTTP client ignores PostForm and uses Body instead.
PostForm url.Values
So your code needs to change from:
c.Infof("%v", resp.Request.PostForm)
To something like this (I haven't tested it for accuracy in the string handling): bd, _ := ioUtil.ReadAll(resp.Body) c.Infof("%v", string(bd[:len(bd)])