簡體   English   中英

如何使用Live REST API創建聯系人?

[英]How to create contacts with Live REST API?

我在使用Java的Live REST API上遇到了一個真正的問題。

確實,我正在嘗試從用戶ID(登錄后)獲取聯系人並插入新聯系人。 但是我有一個“標題”問題。

這是我的連接功能:

$(window).ready(function() {
    $("#ifConnect").hide();

    WL.login({
        scope: "wl.signin, wl.basic, wl.emails, wl.contacts_create"
    }).then(
        function (response) {
            loadContacts(); //which load properly my contacts
        }
    );
});

這是我的創建聯系方式:

var contact = { 
    first_name: "First", 
    last_name: "Last"
};

WL.api({
    path: "me/contacts", 
    method: "POST",
    body: contact
}).then(
    function (response) {
        alert(JSON.stringify(response));
    },
    function (response) {
        alert(JSON.stringify(response));
    }
);

不幸的是,調用了第二個函數,並且給了標題警報: {"error":{"code":"request_body_invalid_media_type","message":"The request doesn't include a Content-Type header."}}

有人可以幫助我嗎? 非常感謝 !

錯誤描述非常有用。 嘗試將Content-Type設置為application / json或將主體放在此示例中:

 function (response) {
         WL.api({
            path: "me/contacts",
            method: "POST",
            body: {
                "first_name": "First",
                "last_name": "Last"
            } 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM