2012-01-12 101 views
0

當試圖POST狀態更新到LinkedIn,我得到401未授權錯誤。我在我的LinkedIn應用程序中將Live狀態更改爲Live但問題仍然存在。我嘗試http://simplelinkedin.fiftymission.net/demo/,但我仍然得到401錯誤...一切都很好GET請求(獲取用戶配置文件數據,...)。錯誤401與LinkedIn API POST請求

這裏是請求數據:

POST /v1/people/~/shares HTTP/1.1 
Host: api.linkedin.com 
Connection: close 
User-Agent: CakePHP 
content-type: application/x-www-form-urlencoded 
x-li-format: json 
Authorization: OAuth oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="2z82i0j5ahjb",oauth_token="2de47758-86e1-4684-afd3-f55a56051d2d",oauth_nonce="03aae214a19e83fe2757e8061a4b1468",oauth_timestamp="1326363432",oauth_signature="WNbKgq1FnkIgIALI%2FMfVnBHLgTg%3D" 
Content-Length: 131 

{"comment":"I am tesing CakePHP","content":{"title":"","submitted-url":"","submitted-image-url":""},"visibility":{"code":"anyone"}} 

這裏是響應數據:

HTTP/1.1 401 Unauthorized 
Server: Apache-Coyote/1.1 
Date: Thu, 12 Jan 2012 10:17:12 GMT 
Vary: * 
x-li-format: json 
Content-Type: application/json;charset=UTF-8 
Content-Length: 230 

{ 
    "errorCode": 0, 
    "message": "[unauthorized]. OAU:2z82i0j5ahjb|2de47758-86e1-4684-afd3-f55a56051d2d|*01|*01:1326363432:WNbKgq1FnkIgIALI/MfVnBHLgTg=", 
    "requestId": "5XSUW613R2", 
    "status": 401, 
    "timestamp": 1326363433324 
} 

任何人可以幫助我調試此得到它解決了嗎?謝謝!

回答

2

發現問題! Content-Type必須爲application/json才能工作!我以爲x-li-format:json就夠了,但它不是。