Hubspot API using PUT not working in VB.NET


#1

When I run the following URI in Fiddler with the accompanying json in the body, it works perfect and unsubscribes the contact. However when I do this is VB.NET with the following code, it does not work and yet returns no error. I use this same VB.NET method to access another Hubspot API in order to update a contacts information with no problems, only it is a “POST” not a “PUT”. Is there a different way I should be doing a “PUT”?

Using wc As New WebClient()
     wc.UploadString("https://api.hubapi.com/email/public/v1/subscriptions/" & email & "?hapikey=mySecretHapiKey", "PUT", "{""unsubscribeFromAll"": true}")
End Using

#2

I found the problem. Just in case anyone else runs into this issue, just add a header:

wc.Headers(HttpRequestHeader.ContentType) = "application/json"