简体   繁体   English

LinkedIn API调用url编码

[英]LinkedIn API call with url encoded

For example, if I make a call to: 例如,如果我拨打电话:

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

It should work fine, but if the URL encoded (and it should be) like this: 它应该工作正常,但如果URL编码(它应该是)像这样:

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

I get this error message: 我收到此错误消息:

<?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>

How can you deal with that? 你怎么能处理这个?
Currently I cannot change the code because my language (Golang btw) do very properly encode this with standar package. 目前我无法更改代码,因为我的语言(Golang btw)使用标准包进行了非常正确的编码。 Here is my code: 这是我的代码:

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)

Do you have solution for this issue except rewrite std lib code? 除了重写std lib代码之外,你有解决这个问题的方法吗?

Some what face with the same issue since 2013 here https://developer.linkedin.com/forum/edit-i-dont-way-uris-look 自2013年以来面临同样问题的一些问题https://developer.linkedin.com/forum/edit-i-dont-way-uris-look

Set the URL Opaque field to the path after creating the request: 创建请求后,将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)

The URL type documentation describes how to do this. URL类型文档描述了如何执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM