2015-12-02 72 views
0

我使用Yammer數據導出API將數據提取到本地,使用curl發送請求。Yammer數據導出API顯示HTTP/1.1 400錯誤請求

$AT #access token 
curl -v --output export.zip \ 
    --header "Authorization: Bearer $AT" \ 
    --get --data-urlencode since=$DATE \ 
    "https://www.yammer.com/api/v1/export" 

如實施例所示在:https://developer.yammer.com/docs/data-export-api

雖然它總是顯示錯誤時請求來檢索數據。

* Connected to www.yammer.com (192.168.1.1) port 443 (#0) 
* successfully set certificate verify locations: 
* CAfile: none 
    CApath: /etc/ssl/certs 
* SSLv3, TLS handshake, Client hello (1): 
} [data not shown] 
* SSLv3, TLS handshake, Server hello (2): 
{ [data not shown] 
* SSLv3, TLS handshake, CERT (11): 
{ [data not shown] 
* SSLv3, TLS handshake, Server key exchange (12): 
{ [data not shown] 
* SSLv3, TLS handshake, Server finished (14): 
{ [data not shown] 
* SSLv3, TLS handshake, Client key exchange (16): 
} [data not shown] 
* SSLv3, TLS change cipher, Client hello (1): 
} [data not shown] 
* SSLv3, TLS handshake, Finished (20): 
} [data not shown] 
* SSLv3, TLS change cipher, Client hello (1): 
{ [data not shown] 
* SSL connection using ECDHD-RSA-AES256-GCU-SSA324 
* Server certificate: 
* start date: 2013-01-01 00:00:00 GMT 
* expire date: 2017-01-01 12:00:00 GMT 
* subjectAltName: www.yammer.com matched 
* SSL certificate verify ok. 
> GET /api/v1/export HTTP/1.1 
> User-Agent: curl/7.35.0 
> Host: www.yammer.com 
> Accept: */* 
> Authorization: Bearer 12252-xxxxxxxx 
> 
< HTTP/1.1 400 Bad Request 
< Date: Wed, 31 Nov 2015 16:06:49 GMT 
< Content-Type: application/zip 
< Transfer-Encoding: chunked 
< 
{ [data not shown] 
* Connection #0 to host www.yammer.com left intact 

我使用的訪問令牌屬於經過驗證的管理,它的確定基於此訪問令牌使用REST API。

任何人都可以給我關於它的建議嗎?

+0

爲什麼www.yammer.com解析爲192.168.1.1? – Brian

+0

不,它解析爲公司的IP – Alan

+0

它看起來像HTTP 400是因爲驗證的管理員訪問令牌無效,我使用它找到了Yammer App Authorization來檢索訪問令牌,如以下網址所述:https:// developer .yammer.com /文檔/ OAuth的2。再加上檢查current.json,它顯示我正在使用經過驗證的管理令牌的令牌。如果有其他方式可以獲得驗證的管理員訪問令牌,但從authorization_code發佈除外?因爲現在檢索到的這個標記是無效的。 – Alan

回答

0

您是否設置了$ DATE? export.zip中是否有任何調試信息(壓縮或其他)?

+0

我已設置%DATE,該zip文件不包含數據,但包含損壞的zip文件。我也試過使用wget,它顯示了同樣的錯誤400錯誤的請求。另外,使用curl來檢索.json(REST API)時顯示正確。我在想如果這個程序需要通過域帳戶的機器運行。現在我正在外部電腦下運行它。 – Alan

+0

如果你'cat'的ZIP文件會發生什麼?我懷疑這不是一個損壞的ZIP文件,而是服務器發回一個錯誤,該錯誤存儲在一個名爲export.zip的文件中。如果是這樣的話,Content-Type頭是一個錯誤,應該是'text/plain'。 –