1

Curl command

curl --user "github" --request POST --data '{"description":"Created via API","public":"true","files":{"587":{"content":"adasdaskdasjsadsasdjfcsdjsdjcsdjcsdjcsdjcfsdjsdjfjsdfjsdfsdfsjdfmdsfdsf"}}' https://api.github.com/gists

It then asks for password and gist is created.

This gives a JSON Error:

url = 'https://api.github.com/gists'
auth = ('github','password')
requests.post(url,auth=auth,data={
  "description": "the description for this gist",
  "public": False,
  "files": {
    "file1.txt": {
      "content": "String file contents"
    }
  }
})

Error: {"message":"Problems parsing JSON","documentation_url":"https://developer.github.com/v3"}

Any ideas where my request is going wrong ?

user3754971
  • 79
  • 1
  • 7

1 Answers1

0

I know this is an old question, but if anybody stumbles in here like I did:

If you're using version 2.4.2 of requests or newer, you should be able to use requests.post(url, json=<your dictionary>).

See this answer for more details: Python Request Post with param data

Community
  • 1
  • 1
steinar
  • 9,383
  • 1
  • 23
  • 37