Как я могу опубликовать json в Google people.api - PullRequest
0 голосов
/ 15 января 2020

создавая контакт, я всегда получаю ответ

Неверно JSON получена полезная нагрузка. Неизвестное имя

my str Json is

{
  "names": [
    {
      "familyName": "NN"
    }
  ]
}
Set web_HTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
    web_Url_CreateContacts = "https://people.googleapis.com/v1/people:createContact"
    web_HTTP.Open "Post", web_Url_CreateContacts & "?" & _
        "access_token=" & Token & "&" & _
        "key=" & ApiKey & "&" & _
        strJson

Ответы [ 2 ]

0 голосов
/ 17 января 2020

Большое спасибо!

Эту идею я упустил!

str JSON необходимо отправить как тело (XMLHttpRequest.send (body)).

0 голосов
/ 15 января 2020

Похоже, вы помещаете str Json как часть строки запроса, что, вероятно, должно означать, что она должна быть закодирована. Но я бы препятствовал этому. Лучше опубликовать с параметром RequestBody в winHTTP, чем пытаться поместить все это в одну строку. и размещение.

    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

   'list
    '~~> Indicates that page that will receive the request and the type of request being 
    submitted
    xmlhttp.Open "POST", 
    "https://www.example.com/api/go/XSx/rest/inquiry/resolveXInquiry", False
    '~~> Indicate that the body of the request contains form data
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 
    ''or JSON content type
    '~~> Send the data as name/value pairs
    '["50061555", "50055854", "500615516", "500615576", "50055910"]
    xmlhttp.send "request={""inquiryIds"":[50061333],""requestType"":""Report2"",""from"":""*parameter"",""comment"":""report""}"
...