Python Code is works well
import os
import sys
import urllib.request
client_id = "123"
client_secret = "456"
url = "https://openapi.naver.com/v1/datalab/search";
body = "{\"startDate\":\"2021-08-01\",\"endDate\":\"2021-09-14\",\"timeUnit\":\"date\",\"keywordGroups\":[{\"groupName\":\"Google\",\"keywords\":[\"한글\",\"korean\"]}]}";
request = urllib.request.Request(url)
request.add_header("X-Naver-Client-Id",client_id)
request.add_header("X-Naver-Client-Secret",client_secret)
request.add_header("Content-Type","application/json")
response = urllib.request.urlopen(request, data=body.encode("utf-8"))
rescode = response.getcode()
if(rescode==200):
response_body = response.read()
print(response_body.decode('utf-8'))
else:
print("Error Code:" + rescode)
Buy my R code is not work
require(httr)
headers = c(
'X-Naver-Client-Id' = '123',
'client_secret' = '456'
)
data = "{\"startDate\":\"2021-08-01\",\"endDate\":\"2021-09-14\",\"timeUnit\":\"date\",\"keywordGroups\":[{\"groupName\":\"google\",\"keywords\":[\"한글\",\"korean\"]}]}"
res <- httr::POST(url = 'https://openapi.naver.com/v1/datalab/search', httr::add_headers(.headers=headers), body = data)
What is problem?
I think the header is not delivered.
I searched a lot, but I don't know. I need help.