2014-01-08 59 views
0

我的网址是喜欢称之为REST API:如何使用curl和SAML令牌验证

https://<ip:port>/TestRESTServices/objects/test-folder 
,我想通过

JSON数据是:

{ 
    "name":"test-1", 
    "parent-uuid":"126" 
} 

测试-1是文件夹的名称,其我想创建。 当我通过POST在Firefox中的海报插件中的数据调用此网址时,它工作正常,文件夹测试-1被创建。

//using Content Type : "application/json" 

如何使用cURL调用/调用此REST API? 需要帮助。

这是我的尝试:

curl -i -H "Accept: application/json" -X POST -d '{"name":"test-1","parent-uuid":"126"}' https://<ip:port>/TestRESTServices/objects/test-folder 

它抛出一个错误curl: (52) Empty reply from server

回答

1

不幸的是我没有一个REST API网上尝试,但我发现资源提出了以下方法:

curl -v -H "Content-Type: application/json" -X POST --data "@issue.json" -u login:password http://redmine/issues.json 

其中issues.json是一个包含JSON请求的文件。

资源,我发现有用:

12

希望它能帮助!

进行身份验证:给用户名/密码管理:密码

TOKEN=$(curl -s -k -X POST --basic -u "admin:password" "{host}/TestAuthServices/auth/tokens" | sed -rn 's/\{"Token":"([^"]+)".+/\1/p') 

得到这个令牌通话卷曲如后:

curl -s -k -X POST -H "Content-Type: application/json" -H "Authorization: X-SAML ${TOKEN}" -d '{"name":"test","parent-uuid":"126"}' "{host}/TestRESTServices/objects/test-folder" 
+0

SAML_AUTH_TOKEN为此,需要对Authentification.Do你有什么想法? –

+0

我想你的服务需要验证。我不知道SAML是如何工作的,但我想首先必须进行身份验证调用,它会返回一个有效的令牌,然后在每次调用中将其用作头。 –

+0

@VaibhavJain您是否解决了SAML问题? –