2017-03-10 6 views
2

を送信した後、ユーザーの変更に従います。Googleドライブに接続した後、googleドライブAPI呼び出しのEntity.resourceエラー

credentials = json.loads(flow.step2_exchange(code).to_json()) 

headers = {'Authorization': 'Bearer {}'.format(credentials['access_token']), 'Content-Type': "application/json"} 
token_url = 'https://www.googleapis.com/drive/v3/changes/startPageToken' 

token_resp = requests.get(token_url, headers=headers) 
pageToken = json.loads(token_resp.content)['startPageToken'] 

url = 'https://www.googleapis.com/drive/v3/changes/watch?pageToken={}&alt=json'.format(pageToken) 
headers = {'Authorization': 'Bearer {}'.format(credentials['access_token']),} 
data = { 
    "id": str_tools.random_str(40), 
    "type": "web_hook", 
    "address": my_url 
} 

response = requests.post(url, data=json.dumps(data), headers=headers) 

と私はそれが "entity.resource" を意味しないとどのように私はこのエラーに

感謝を修正することができますどのような

{ 
    "error": { 
     "errors": [ 
      { 
       "domain": "global", 
       "reason": "required", 
       "message": "entity.resource" 
      } 
     ], 
     "code": 400, 
     "message": "entity.resource" 
    } 
} 

このエラーを受けています。

+0

私はインターネットを検索しますが、実際の意味を見つけることができず、エラー「entity.resource'」が原因です。通常、エラーコード400は、Webページをロードするリクエストのような単純なものが、何らかの形で間違っているか破損していて、サーバーがそれを理解できなかったということを意味します。だからあなたがそれを助けることができる場合は、この種のエラーを持ってこれを確認しようとすると([質問])(http://stackoverflow.com/questions/25414767)。 – KENdi

+0

リクエストヘッダーに ''Content-Type': 'application/json''を追加するのを忘れました:) –

答えて

0

リクエストヘッダーに'Content-Type': 'application/json'を追加するのを忘れました。

関連する問題