【问题标题】:Curl and Git Bast POST requestCurl 和 Git Bash POST 请求
【发布时间】:2018-09-26 21:25:19
【问题描述】:

我正在使用 GIT BASH 在 Curl 中进行 POST Resquest。我是这种请求的新手。我在这里做错了什么?感谢您的建议,这是我第一次尝试这种我不完全理解的请求。这是我正在关注的教程:https://developer.here.com/documentation/batch-geocoder/topics/request-submit.html

还有其他解决方案吗?

这是我的代码:

Curl 和 Git Bast POST 请求

$ curl https://batch.geocoder.cit.api.here.com/6.2/jobs
mailto={simere.com}
&gen=8
&header=true
&indelim=%7C
&outdelim=%7C
&outcols=displayLatitude,displayLongitude,locationLabel,
houseNumber,street,district,city,postalCode,
county,state,country
&outputCombined=false
&app_code={ OBasqavTxfN1}
&app_id={RfsseIcVfmV7w}
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   286  100   286    0     0    295      0 --:--:-- --:--:-- --:--:--   295{"error":"Bad Request","error_description":"The r                equest is missing the app_id and app_code parameters. They must both be passed as query parameters. If you do not have app_id a                nd app_code, please obtain them through your customer representative or at http://developer.here.com/myapps."}

renau@DESKTOP-2EC3B6J MINGW64 ~
$ ?action=run
bash: ?action=run: command not found

renau@DESKTOP-2EC3B6J MINGW64 ~
$ mailto={simon.re.com}

renau@DESKTOP-2EC3B6J MINGW64 ~
$ &gen=8
bash: syntax error near unexpected token `&'

renau@DESKTOP-2EC3B6J MINGW64 ~
$ &header=true
bash: syntax error near unexpected token `&'

renau@DESKTOP-2EC3B6J MINGW64 ~
$ &indelim=%7C
bash: syntax error near unexpected token `&'

renau@DESKTOP-2EC3B6J MINGW64 ~
$ &outdelim=%7C
bash: syntax error near unexpected token `&'

renau@DESKTOP-2EC3B6J MINGW64 ~
$ &outcols=displayLatitude,displayLongitude,locationLabel,
bash: syntax error near unexpected token `&'

renau@DESKTOP-2EC3B6J MINGW64 ~
$ houseNumber,street,district,city,postalCode,
bash: houseNumber,street,district,city,postalCode,: command not found

renau@DESKTOP-2EC3B6J MINGW64 ~
$ county,state,country
bash: county,state,country: command not found

renau@DESKTOP-2EC3B6J MINGW64 ~
$ &outputCombined=false
bash: syntax error near unexpected token `&'

renau@DESKTOP-2EC3B6J MINGW64 ~
$ &app_code={ OBascvTxfN1}
bash: syntax error near unexpected token `&'

renau@DESKTOP-2EC3B6J MINGW64 ~
$ &app_id={RfsseIQvcVfmV7w}
bash: syntax error near unexpected token `&'

【问题讨论】:

    标签: curl git-bash


    【解决方案1】:

    查看页面“Tools”:

    使用“wget”和“cURL”提交作业时,请检查输入和输出请求中的字段名称(例如,&outCols=recId,…)和字段分隔符。
    wget如果输入错误或分隔符与输入文件中的分隔符不匹配,cURL 将返回“400 Bad Request”响应。
    wgetcURL 都需要在标头中指定内容类型。
    目前不支持上传压缩地址数据

    如果您使用cURL,请务必添加以下标头

    Content-Type: text/plain
    

    并使用--data-binary 参数提交有效负载。

    例子:

    curl -X POST -H "Content-Type: text/plain" --data-binary @addresses.txt
      "https://batch.geocoder.cit.api.here.com
    /6.2/jobs?
      &app_code={YOUR_APP_CODE}
      &app_id={YOUR_APP_ID}
      &action=run
      &header=true
      &inDelim=;
      &outDelim=,
      &outCols=recId,latitude,longitude,locationLabel
      &mailto={YOUR_EMAIL}
      &outputcombined=true
      &language=de-DE"
    

    【讨论】:

    • 我是新手,我正在尝试了解如何使用原始格式。如果我想在不使用 wget 或 curl 的情况下将原始格式保留在哪些工具、软件中运行我的 http 请求?有什么选择?
    • "不使用 wget 或 curl?"你的问题是特别是关于 curl:这就是我的回答所要解决的问题。
    • 是的,正确的。我也想知道在“什么”中我可以用原始格式对这个 Post 请求进行编码?
    • @Simre 该命令可以在 shell 中使用,也可以在 shell 中执行的脚本中使用。
    猜你喜欢
    • 2020-06-23
    • 2015-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-28
    • 2019-01-17
    • 2015-05-25
    • 2018-09-14
    相关资源
    最近更新 更多