我如何将json发布到google people.api

通过创建联系人, 我总是得到答案

接收到无效的JSON有效负载。未知名称

我的strJson是

{
  "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

my183300 回答:我如何将json发布到google people.api

似乎您将strJson放在查询字符串中,这意味着应该对它进行urlencode编码。但是我不建议这样做。最好使用winHTTP的RequestBody参数进行发布,而不是尝试将其全部放入一个字符串中。和发布。

    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""}"
,

非常感谢!

那是我想念的想法!

strJSON必须作为正文(XMLHttpRequest.send(正文))发送。

本文链接:https://www.f2er.com/2764538.html

大家都在问