簡體   English   中英

LinkedIn API調用url編碼

[英]LinkedIn API call with url encoded

例如,如果我撥打電話:

https://api.linkedin.com/v1/people/~:(id,first-name,last-name)

它應該工作正常,但如果URL編碼(它應該是)像這樣:

https://api.linkedin.com/v1/people/~:%28id,first-name,last-name%29

我收到此錯誤消息:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
    <status>404</status>
    <timestamp>1423577265744</timestamp>
    <request-id>6B2UQSA25W</request-id>
    <error-code>0</error-code>
    <message>[invalid.property.name]. Couldn&#39;t find property with name {:%28id,first-name,last-name%29} in resource of type {Person}</message>
</error>

你怎么能處理這個?
目前我無法更改代碼,因為我的語言(Golang btw)使用標准包進行了非常正確的編碼。 這是我的代碼:

r, _ := http.NewRequest("GET", "https://api.linkedin.com/v1/people/~:(id,first-name,last-name)", nil)
r.Header.Set("Authorization", "Bearer "+respBody.AccessToken)
resp, err = http.DefaultClient.Do(r)

除了重寫std lib代碼之外,你有解決這個問題的方法嗎?

自2013年以來面臨同樣問題的一些問題https://developer.linkedin.com/forum/edit-i-dont-way-uris-look

創建請求后,將URL Opaque字段設置為路徑:

r, err := http.NewRequest("GET", "https://api.linkedin.com", nil)
if err != nil {
  // handle error
}
r.URL.Opaque = "/v1/people/~:(id,first-name,last-name)"
r.Header.Set("Authorization", "Bearer "+respBody.AccessToken)
resp, err = http.DefaultClient.Do(r)

URL類型文檔描述了如何執行此操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM