开发者社区 问答 正文

阿里云OpenAPI post是post contenttype 我不知道是哪个?

阿里云OpenAPI post是post contenttype 我不知道是哪个? 现在表单和json我都成功不了c01d2b6959918f32105e5700640b1f7c.png

展开
收起
真的很搞笑 2023-09-16 20:19:45 161 分享 版权
2 条回答
写回答
取消 提交回答
  • 对于HTTP POST请求,Content-Type是一个重要的头信息,它告诉服务器你正在发送的内容是什么类型的。一般来说,对于JSON数据,我们应该设置Content-Type为application/json。

    在JavaScript中,你可以这样做:

    var xhr = new XMLHttpRequest();
    xhr.open("POST", "your_url_here"); // 替换为你的URL
    xhr.setRequestHeader("Content-Type", "application/json"); // 这里设置为JSON
    xhr.send(JSON.stringify({key1: value1, key2: value2})); // 这里是你的JSON数据
    

    在Python中,你可以这样做:

    import requests
    headers = {"Content-Type": "application/json"}
    response = requests.post("your_url_here", data=json.dumps({key1: value1, key2: value2}), headers=headers)
    
    2023-09-17 09:04:59
    赞同 展开评论
  • roa的contenttype是JSON的,此回答整理自钉群“阿里云 OpenAPI SDK 自签名服务群”

    2023-09-17 07:47:52
    赞同 展开评论