0

I am using Chilkat objects and would like to be able to send a PATCH JSON string to a URL endpoint in vbscript. My POST works great, however, I can't seem to find a way to send a PATCH. The call to send a POST is: set resp = http.PostJson(URL, ResultStr). How do I send a PATCH JSON string using similar Chilkat method? Below is my code:

ResultStr = BuildJSONUpdatedResults()

set http    = CreateObject("Chilkat_9_5_0.Http")
success = http.AddQuickHeader("content-type","application/json")
success = http.AddQuickHeader("Authorization",auth)

set resp = http.PostJson(URL, ResultStr)

Thanks a lot.

Ahmed
  • 19
  • 1
  • 1
  • 3
  • 1
    You originally asked [How to do a POST and GET in VBscript?](//stackoverflow.com/a/52770844) back in October and got a succinct answer that also pointed you to [the documentation](http://www.chilkatsoft.com/refdoc/xChilkatHttpRef.html). Have you read through it? From what I can see `PATCH` is not supported with a specific `PatchJson()` method but there is `PText()` which supports `POST`, `PUT` and `PATCH`. Personally, I would move away from the COM component and use WinHttp instead. – user692942 Dec 07 '18 at 16:28
  • 1
    [Here's an example](https://stackoverflow.com/a/37462944/692942) of using the WinHttp component in VBScript. – user692942 Dec 07 '18 at 16:35
  • Thank you Lankymart. You're awesome – Ahmed Dec 07 '18 at 20:56

2 Answers2

2

Use the REST object, instead.

      loRest.AddHeader("Content-Type","application/json")
      loRest.AddHeader("Authorization","Bearer "+this.token)
      loRest.AddHeader("X-Upload-Content-Type",this.contentType)
      loJson.UpdateString("name",this.remoteFile)
      set lcResponseStr = loRest.FullRequestString("PATCH", "/upload/drive/v3/files/"+fileToBeUpdated+"?uploadType=resumable, loJson.emit)
0

You would call PText instead, like this:

set resp = http.PText("PUT",URL,ResultStr,"utf-8","application/json", 0, 0)
Chilkat Software
  • 1,405
  • 1
  • 9
  • 8
  • Why have all the `POST` and `GET` helper methods but not one for `PUT` or `PATCH`? Where is the `PatchJson()` method? *Asking you this on the assumption you either own or work for [Chilkat Software Inc](http://www.chilkatsoft.com/corporate.asp).* – user692942 Dec 11 '18 at 10:00