0

I need to integrate the Autodesk PLM 360 service into SolidWorks and am using VBA to accomplish that. In order to initiate the HTTP requests, I am using the following code:

Dim objHTTP As MSXML2.ServerXMLHTTP
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.setRequestHeader "Content-Type", "application/xml" '<-- Error occurs here
objHTTP.Open "POST", "https://mytenant.autodeskplm360.net/rest/auth/1/login", False
objHTTP.send "<metaFields>" & _
                "<password>MyPassword</password>" & _
                "<userID>MyUserID</userID>" & _
             "</metaFields>"

The third line from the above code trips the following error:

Unspecified error

When I comment out the offending line, the status returned from the HTTP request is "415 - Unsupported Media Type".

Is there anyone that can make sense out of what the problem is here? All the searches I've done haven't helped at all.

P.S. I should also note that the same problem occurs in Excel too, so it isn't due to something strange that the SolidWorks implementation of VBA is doing.

tlewis3348
  • 424
  • 2
  • 7
  • 21

1 Answers1

0

As @barrowc points out in a comment, the setRequestHeader command needs to follow the open command. It should look like this:

Dim objHTTP As MSXML2.ServerXMLHTTP
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.Open "POST", "https://mytenant.autodeskplm360.net/rest/auth/1/login", False
objHTTP.setRequestHeader "Content-Type", "application/xml"
objHTTP.send "<metaFields>" & _
                "<password>MyPassword</password>" & _
                "<userID>MyUserID</userID>" & _
             "</metaFields>"
tlewis3348
  • 424
  • 2
  • 7
  • 21