You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Dyalog APL的HttpCommand中POST原始数据?

使用HttpCommand提交纯文本POST请求的等效实现

对应你提供的cURL命令:

curl -request POST "http://my-api-url" --header "Content-Type: text/plain" --data-raw "here is my test"

等效的HttpCommand实现

可以通过两种方式实现:

分步配置方式

; 创建HttpCommand实例
hc ← ⎕NEW HttpCommand
; 设置请求地址
hc.URL ← 'http://my-api-url'
; 指定POST请求方法
hc.Method ← 'POST'
; 设置Content-Type头部
hc.Headers ← ⊂'Content-Type: text/plain'
; 传入纯文本数据
hc.Data ← 'here is my test'
; 执行请求并获取结果
result ← hc.Run

链式简洁写法

result ← ⎕NEW HttpCommand('POST' 'http://my-api-url' ('Content-Type: text/plain') 'here is my test').Run

关键说明

  • 通过Method属性指定请求方法为POST
  • 在Headers中添加Content-Type: text/plain,保证服务端能正确解析纯文本数据
  • 将纯文本内容直接赋值给Data属性,这与cURL的--data-raw参数作用一致,HttpCommand会自动处理数据的传输格式

内容的提问来源于stack exchange,提问作者RikedyP

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 04:49:53