0

I am trying to send data through HTTP POST from an Excel/VBA script to an API I built in Google Apps script. The Google script executes correctly, but always returns a 405 "Method not allowed" and the return value is an HTML page from Google Drive. When I send the same POST from Postman, I get status 200 and the return value is he one that is implemented in the Google script.

The Google apps minimal test script that I used:

function doPost(e) {
  
  
return ContentService.createTextOutput("Gelukt").setMimeType(MimeType.JSON);

}

The relevant code in VBA:

With objHTTP
    .Open "POST", Url, False
    .setRequestHeader "Content-Type", "text/plain"
    .setRequestHeader "Accept-Language", "en-US"
    .send JsonString
End With

When I send the POST request to webhook.site it shows this:enter image description here

I tried all suggestions I could find, but nothing changes the 405!

Hubert1957
  • 211
  • 2
  • 16
  • The Content-Type is different in your webhook example. Does it work in VBA if you try `"content-type", "application/json"`? – Toddleson May 09 '23 at 21:51
  • Seems related - https://stackoverflow.com/questions/74878421/google-apps-script-return-405-for-post-request If you use GET does it work? – Tim Williams May 09 '23 at 22:33

0 Answers0