0

に連絡先を挿入しようとしていますMirror APIが、400 Bad Requestエラーが発生し続けます。

リクエストを作成するための私のコードは次のとおりです。

    Http h = new Http();
    HttpRequest firstPost = new HttpRequest();
    firstPost.setEndpoint('https://www.googleapis.com/mirror/v1/contacts');
    firstPost.setMethod('POST');
    firstPost.setHeader('Authorization', 'Bearer ' +access_token);
    System.debug('Bearer '+access_token);
    firstPost.setBody(postBody);
    firstPost.setHeader('Content-Type', 'application/json');

現在、postBody は次のようにハードコードされています。

{
 "kind":"mirror#contact",
 "id":"harold",
 "displayName":"Harold Penguin",
 "imageUrls": ["https://developers.google.com/glass/images/harold.jpg"]
}

access_tokenが送信されていることを確認しました。何か案は?ありがとう!

4

1 に答える 1

0

kindを実行するときは、属性は必要ありません (指定する必要はありません) contact.insert。これは想定されており (連絡先を挿入した方がよい)、提供した場合に問題が発生する可能性があることがわかります。https://developers.google.com/glass/v1/reference/contacts/insertには属性としてリストされておらず、Raw HTTP の例には表示されていないことに注意してください。

于 2013-10-17T15:50:23.153 に答える