2014-01-08 63 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問題? –