首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发送和HTTPS post到DPD API,不起作用

发送和HTTPS post到DPD API,不起作用
EN

Stack Overflow用户
提问于 2015-11-04 23:55:33
回答 1查看 952关注 0票数 0

我正在尝试从我的终端发出curl请求,以使用以下命令连接到DPD API:

$ sudo curl -H "Content-Type=application/json" -H "Authorization: Basic RFNNSVRIOk1ZUEFTU1" -H "GEOClient: account/12345" https://api.dpd.co.uk/user/?action=login,但是我一直收到这个错误

Cannot GET /esgServer/user/?action=login

从文档中,我得到了以下内容:

代码语言:javascript
复制
3.1.1. API Login
URL=POST:/user/?action=login
Every API requires a geoSession except the Login which returns the geoSession which should be 
passed into any further API calls. 
This API sets up a session on the GeoPost servers in whic
h all 
future requests validate against. 
The API requires the username and password base64 encrypting 
and passed across as an Authorization header in the HTTP request, example:
username = DSMITH
password = MYPASSWD
concatenate the username and password wit
h a colon in between and encrypt to base64 as a single 
string:
DSMITH:MYPASSWD
this would result in a string of:
RFNNSVRIOk1ZUEFTU1dE
which can be applied to the http request as a header of:
Authorization: Basic RFNNSVRIOk1ZUEFTU1dE
A returning http respo
nse code of 401 means the username or password are incorrect
Supported HTTP Headers
content
-
type
None
Accept
application/json
Example Request is shown below:
POST /user/?action=login HTTP/1.1
Host: api.dpd.co.uk
Content
-
Type: application/json
Accept: 
application/json
Authorization: Basic RFNNSVRIOk1ZUEFTU1dE
GEOClient: account/123456
Content
-
Length: 0

我遗漏了什么?

如有任何建议,我们将不胜感激

EN

回答 1

Stack Overflow用户

发布于 2015-11-05 00:08:44

我忘了在命令行中添加-X POST

所以

代码语言:javascript
复制
sudo curl -H "Content-Type=application/json" -H "Authorization: Basic  RFNNSVRIOk1ZUEFTU1" -H "GEOClient: account/12345" -X POST https://api.dpd.co.uk/user/?action=login
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33526272

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档