how to POST contents of JSON file to RESTFUL API with Python using requests module

前端 未结 4 1677
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-25 15:30

Okay, I give up. I am trying to post the contents of a file that contains JSON. The contents of the file look like this:


{
     \"id”:99999999,
              


        
4条回答
  •  借酒劲吻你
    2020-12-25 15:49

    I have done below code while learning Open API and works fine for me.

    `
    import requests
    url="your url"
    json_data = {"id":"k123","name":"abc"}
    resp = requests.post(url=url,json=json_data)
    print(resp.status_code)
    print(resp.text)
    `
    

提交回复
热议问题