输入/搜索内容
1
关注
82
关注者
HttpQuery body
帮助
创建于 2019-08-26 03:44:58  
 8
 1989

HttpQuery 函数中可以传递 header, PostData等,请问如何传递 Body 的内容?

评论
全部评论 (8)

    大佬,看了你的韭菜收割机策略的交流贴,有问题想请教,可以加你微信吗?

    7 年前
    J

    发完帖子才发现文件头可以自己定义的,是我糊涂了。
    经过测试 HttpQuery 使用 “application/json” 没有问题。谢谢大家的帮忙!

    7 年前

    你好, 测试没有问题的, 可能是这个网站 把 Content-Type 为 "application/x-www-form-urlencoded" 的HTTP头做了转换

    7 年前
    J

    多谢站长帮忙!

    是的,本站实现的HttpQuery POST方式采用的是默认的方式 "application/x-www-form-urlencoded"

    默认模式 "application/x-www-form-urlencoded"
    命令行: curl -X POST -d 'Test=12' -v -i 'https://ptsv2.com/t/tcj88-1566874165/post'
    运行结果: https://ptsv2.com/t/tcj88-1566874165/d/399480296

    或者: curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d 'Test=123' -v -i 'https://ptsv2.com/t/tcj88-1566874165/post'
    运行结果: https://ptsv2.com/t/tcj88-1566874165/d/374760737
    这种模式下,服务器接收的数据都体现在 Parameters 部分

    POST 还可以使用 “application/json”, "multipart/form-data" 等方式提交数据,只要修改下数据头 Content-Type 就可以了。

    命令行: curl -X POST -H "Content-Type: application/json" -d {"test":"1234"} 'https://ptsv2.com/t/tcj88-1566874165/post'
    运行结果: https://ptsv2.com/t/tcj88-1566874165/d/374760773
    这种模式下,服务器接收的数据体现在 Body 部分

    命令行: curl -X POST -H "Content-Type: multipart/form-data; boundary=----------------------------BOUNDARY" -d $'------------------------------BOUNDARY\r\nContent-Disposition: form-data; name="Test"\r\n\r\n12345\r\n------------------------------BOUNDARY--\r\n' 'https://ptsv2.com/t/tcj88-1566874165/post'
    运行结果: https://ptsv2.com/t/tcj88-1566874165/d/380571003
    这种模式下,服务器接收的数据体现在 Multipart Values 或者 Multipart Files 里面

    请站长能将 HttpQuery 函数增加个对文件头 Content-Type 的自定义,或者允许使用 "application/json“ 方式提交数据。谢谢!

    7 年前

    你查下API文档, HttpQuery是可以自定义Header头的

    7 年前

    是的,问题解决了,谢谢!

    7 年前

    PostData就是啊

    7 年前
    J

    PostData 传递的是参数,不是Body.

    可以通过 https://ptsv2.com 网站验证
    var query = HttpQuery('https://ptsv2.com/t/tcj88-1566874165/post', 'a=1&b=2&c=3')
    Log(query)

    结果在这里: https://ptsv2.com/t/tcj88-1566874165/d/387920759

    7 年前
  • 1
社区
回测系统
APP 下载
iPhone 下载
© 2015 - ∞ INVENTOR PTE LTD (SG)