以下是我的GET请求
req <- GET(url, add_headers(
c(
"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0",
"Accept":"application/vnd.subdomain.domain.v2+json",
"Authorization":"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJRb2QteEVlSDJNQXJKVjZSRkVoM2g3ZUZ6SGhmMGFPbGphOXJ2SHJld3pBIn0.eyJqdGkiOiI0ODc1MmM5OC1jYTkyLTQwMTItYmY5Ni03YjJiYWVhZDM0ZGQiLCJleHAiOjE1MjAyNTA1MjksIm5iZiI6MCwiaWF0IjoxNTIwMjUwMjI5LCJpc3MiOiJodHRwczovL2xvZ2luLmFrdm8ub3JnL2F1dGgvcmVhbG1zL2Frdm8iLCJhdWQiOiJjdXJsIiwic3ViIjoiOGQyYmJmNTYtYTI3Zi00NDgyLWIzMDYtMjRkNTY3NjhhM2E2IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiY3VybCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImY5ODAzODdhLTJkNzEtNDM4NS1iYTQ0LTQ1ZmEzNDZiMzY4MyIsImFjciI6IjEiLCJjbGllbnRfc2Vzc2lvbiI6IjJlNDNhNGJmLTUyM2YtNDk1Yy04NDY1LTQ5Y2FkNTY2ZGNjNiIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwOi8vbG9jYWxob3N0OjMwMDAiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImFrdm86bHVtZW46dHJpYWw6YWRtaW4iLCJha3ZvOmx1bWVuOndhdGVyc2hlZGtlbnlhOmFkbWluIiwiYWt2bzpsdW1lbjpldGhpb3BpYTphZG1pbiIsImFrdm86bHVtZW46ZXRoaW9waWEiLCJha3ZvOmx1bWVuOmRlbW8iLCJha3ZvOmx1bWVuOmZvb3RiYWxsZm9yd2F0ZXIiLCJha3ZvOmx1bWVuOmZvb3RiYWxsZm9yd2F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y_X8mXNy5tJ8pbaGCagf7nrXyGzZxKer4K__IU8XxRzE2DfBrQoDFXpc7EvIHH8YUusPp6eGnT6InC9dDjKD7X7v1eXitDQVzw",
"not-before-policy":0,
"session_state":"f980387a-2d71-4385-ba44-45fa346b3683"
)
))
使用url
,我正在获取没有查询的端点。
但是,在控制台上,我收到此错误。
Error in "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0" :
NA/NaN argument
In addition: Warning messages:
1: In request(headers = c(..., .headers)) : NAs introduced by coercion
2: In request(headers = c(..., .headers)) : NAs introduced by coercion
我的GET
请求有什么问题?我是否正确编码了?
答案 0 :(得分:2)
错误来自于:
序列运算符与字符串的使用。
c("a":"b")
Error in "a":"b" : NA/NaN argument
In addition: Warning messages:
1: NAs introduced by coercion
2: NAs introduced by coercion
add_headers
期待命名值,因此您应该使用:
add_headers(
"User-Agent" = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0",
...
)