CUC Forums

« Back to CUPI Questions

415 - Unsupported Media Type Error on Pin Reset

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
I am new to REST and I am running into a problem when trying to PUT a request for a pin reset. If I use the same code I have developed with a GET the XML is returned. It seems that I am missing something with the formatting of my PUT request. Any assistance would be greatly appreciated.
 
<%
 dim XmlHttp
 dim PostURL
 dim ResponseXml
 dim sXML
 sXml="<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>"
 sXml=sXml & "<Credential>"
 sXml=sXml & " <EncryptionType>5</EncryptionType><Credentials>44444</Credentials>"
 sXml=sXml & "</Credential>"
 PostURL="http://xx.xxx.xx.xx/vmrest/users/edb8da2b-74b4-43d4-9380-ef208f950dbd/credential/pin"
 
 Set XmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
 XmlHttp.Open "PUT", PostUrl, false,  "cupiuser", "*******"
 XmlHttp.SetRequestHeader "Content-Type", "application/xml"
 XmlHttp.SetRequestHeader "Accept", "application/xml"
 XmlHttp.setOption(2) = 13056
 XmlHttp.send sXML
 ResponseXml = XmlHttp.ResponseText
 Response.ContentType = "application/xml"
 response.write responseXML
%>

you don't need to pass the EncryptionType there - you are setting a PIN and Connection sets the encryption type to SHA1 on the back end regardless - passing 5 (which means no encryption) is bad mo-jo.
You also need to wrap the request in a "credential" tag.

I just issued a PIN reset to the same URI construction using this as the XML payload:

<Credential><Credentials>44332211</Credentials></Credential>

and it set fine.

You can also pass Locked, CredMustChange, DoesntExpire as additional items to the Credentials string itself...