0

I just started using MSXML2.XMLHTTP object with VBA and I'm trying to interact with our Content Server (create, move, copy, delete files).

I found some random working code on the internet but I still do not fully understand what is going on.

Set req As New MSXML2.XMLHTTP

req.Open "MKCOL", "https://company/dav/nodes/" & URIsource & "/" & Encoded_FolderName, False
req.SetRequestHeader "Content-Type", "text/xml"
req.Send 

URIsource is an objID from the server (ie : 12345678)

Encoded_Foldername is the folder name passed into this a function called URLEncode found here

From the OpenText website I tought I was supposed to put :

req.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

But it doesn't work with my code. I must use the previous one.

I also have a function to copy a file and it uses :

 req.setRequestHeader "Destination", strDestURL

How am I supposed to know what Requestheader to use? Is there a list somewhere for post, put, get, etc. ? I understood that "Content-Type" is used to make sure the server understands the request but that's it.

Thank you

Community
  • 1
  • 1
trixrabbit
  • 259
  • 7
  • 22
  • https://en.wikipedia.org/wiki/List_of_HTTP_header_fields ? – Jonathan Lonowski Nov 12 '14 at 21:12
  • From Wiki : Content-Type: text/html; charset=utf-8 is a Response field and Content-Type: application/x-www-form-urlencoded is a Request field, would it be normal to send both? Ask in one format and receive answer in another? – trixrabbit Nov 13 '14 at 17:51
  • Yeah, the request and response are separate messages and can have different `Content-Type`s. The value should be a [media type](https://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types) that describes the body content in the current message when any is included. For XHRs, the body content is the optional argument for `.Send`. And the two formats you mentioned are typical with submitting a `
    ` -- the request sends the form's values and the response sends back the updated markup.
    – Jonathan Lonowski Nov 13 '14 at 18:18
  • I just find this very complicated..I see a lot of examples on internet but I am not able to modify them to work with our server. Some do objHTTP.open "POST", ServerURL, false then ObjHTTP.send postdata...some seems only to open directly to the file and do an empty .send – trixrabbit Nov 13 '14 at 19:38

1 Answers1

0

Request headers contain information about the sender, body of the request and required response.

http://help.dottoro.com/ljhcrlbv.php

Siraj Hussain
  • 874
  • 9
  • 25