I'm following the API referenced here but nothing I am doing seems to be working. Below is my code and the error message I am getting
import requests
access_token = 'MY_ACCESS_TOKEN'
headers = {
"content-type": "application/x-www-form-urlencoded",
"Authorization": f"Bearer {access_token}",
}
url = "https://youtubereporting.googleapis.com/v1/jobs"
data = {
"reportTypeId": "channel_basic_a2",
"name": "my_job",
}
response = requests.post(url, headers=headers, data=data)
# Also tried
# response = requests.post(url, headers=headers, params=data)
assert response.status_code == 200, f"{response.status_code} {response.text}"
print(response.text)
Below is the error message I am getting
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"reportTypeId\": Cannot bind query parameter. Field 'reportTypeId' could not be found in request message.\nInvalid JSON payload received. Unknown name \"name\": Cannot bind query parameter. Field 'name' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"reportTypeId\": Cannot bind query parameter. Field 'reportTypeId' could not be found in request message."
},
{
"description": "Invalid JSON payload received. Unknown name \"name\": Cannot bind query parameter. Field 'name' could not be found in request message."
}
]
}
]
}
content-type": "application/x-www-form-urlencoded"just tryapplication/jsonbecause you are sending a json object in your server. There is an error:Field 'name' could not be found in request message.it means thenamein your attributes cannot be found.