Merge pull request #1093 from cli/api-file

gh api: fix passing file/stdin contents via field arguments
This commit is contained in:
Mislav Marohnić 2020-06-04 12:30:32 +02:00 committed by GitHub
commit 24ca449179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -22,6 +22,12 @@ func httpRequest(client *http.Client, method string, p string, params interface{
if strings.EqualFold(method, "GET") {
url = addQuery(url, pp)
} else {
for key, value := range pp {
switch vv := value.(type) {
case []byte:
pp[key] = string(vv)
}
}
if isGraphQL {
pp = groupGraphQLVariables(pp)
}

View file

@ -157,7 +157,7 @@ func Test_httpRequest(t *testing.T) {
method: "POST",
p: "graphql",
params: map[string]interface{}{
"a": "b",
"a": []byte("b"),
},
headers: []string{},
},