CUC Forums

« Back to CUPI Questions

415 - Unsupported Media Type Error on Pin Reset

Combination View Flat View Tree View
Threads [ Previous | Next ]
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 & " <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
%>

I am no expert but mine is working with a CredentialType of 4, not 5. Haven't found in doc exactly what each means yet.

Ash

Hi ¿ this is what the credentialtype values mean:



3=Password

4=Pin



The XML is actually documented on the server itself. This URL will give you a list of the XML schema files:



https://<server>/vmrest/schema <https://%3cserver%3e/vmrest/schema>



Just go there and click on the one you are interested in, say Credential in this case, and you will get the XML Schema for it that includes comments describing the content.



~ Matt





From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Wednesday, November 09, 2011 6:21 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Ryan Ash in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: RE: 415 - Unsupported Media Type Error on Pin Reset



Ryan Ash has created a new message in the forum "CUPI Questions":

--------------------------------------------------------------
I am no expert but mine is working with a CredentialType of 4, not 5. Haven't found in doc exactly what each means yet.

Ash
--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4728792>

or simply reply to this email.

The issue I am running into is Unsupported Media Type. I am wondering if I am missing something in the XML to post the PUT request?

I have tried this several different ways.

objXML.send "<Credential>" & _
"<UserObjectId>" & sUserObjectId & "</UserObjectId>" & _
"<CredentialType>4</CredentialType>" & _
"<Credentials>" & sPassword & "</Credentials>" & _
"<Locked>0</Locked>" & _
"</Credential>"

I use to get that, but have managed to fix it. I am without Laptop
until Friday, but can try and post something then.

Thanks



On 9 Nov 2011, at 07:16, "Cisco Developer Community Forums" <cdicuser@developer.cisco.com
> wrote:

> Andy Melick has created a new message in the forum "CUPI Questions":
>
> --------------------------------------------------------------
> The issue I am running into is Unsupported Media Type. I am
> wondering if I am missing something in the XML to post the PUT
> request?
>
> I have tried this several different ways.
>
> objXML.send "<Credential>" & _
> "<UserObjectId>" & sUserObjectId & "</UserObjectId>" & _
> "<CredentialType>4</CredentialType>" & _
> "<Credentials>" & sPassword & "</Credentials>" & _
> "<Locked>0</Locked>" & _
> "</Credential>"
> --
> To respond to this post, please click the following link:
>
> <http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4728943
> >
>
> or simply reply to this email.

Registered No. 755780 England
Registered Office: FM Insurance Company Limited
1 Windsor Dials, Windsor,
Berkshire, UK, SL4 1RS
Regulated by the Financial Services Authority.
VAT No. G.B.: 792 4276 02

Simon,

That would be great because I still am getting a 415 Unsupported Media error.

Thanks,

Andy

Hi Andy ¿ the FAQ has an entry on 415 errors:



http://docwiki.cisco.com/wiki/Cisco_Unity_Connection_REST_API_FAQ



Try the suggestion there to see if that helps.



~ Matt



From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, November 10, 2011 9:20 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Andy Melick in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: RE: 415 - Unsupported Media Type Error on Pin Reset



Andy Melick has created a new message in the forum "CUPI Questions":

--------------------------------------------------------------
Simon,

That would be great because I still am getting a 415 Unsupported Media error.

Thanks,

Andy
--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4733260>

or simply reply to this email.

Matt,

I read the wiki document:

What can cause a 415 error?
415 errors are generally caused by not specifying the requested content type. Try setting the "Content-Type" header to "application/xml".

If you look at my code from my orginial post I am using the correct formatting I believe. By all means if someone can tell me hwat is wrong with my code to generate the 415 error HELP!


XmlHttp.SetRequestHeader "Content-Type", "application/xml"

I have set my header to include utf-8, not sure if it helps;
application/xml;charset=utf-8

I have tried that. Do you use ASP or VBScript if so can you share your working code?



From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, November 10, 2011 3:01 PM
To: cdicuser@developer.cisco.com
Subject: New Message from Sascha Monteiro in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: Re: New Message from Andy Melick in Cisco Unity Connection Provisioning Int



Sascha Monteiro has created a new message in the forum "CUPI Questions":
--------------------------------------------------------------
I have set my header to include utf-8, not sure if it helps;
application/xml;charset=utf-8
--
To respond to this post, please click the following link:
<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4734807>
or simply reply to this email.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 6619 (20111110) __________



The message was checked by ESET NOD32 Antivirus.



http://www.eset.com

no sorry, my code is in Java

have you tried using https ?
I recall having problems with http

I have tried it in HTTP and HTTPS and get the same error 415 unsupported media.



From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, November 10, 2011 3:11 PM
To: cdicuser@developer.cisco.com
Subject: New Message from Sascha Monteiro in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: Re: New Message from Andy Melick in Cisco Unity Connection Provisioning Int



Sascha Monteiro has created a new message in the forum "CUPI Questions":
--------------------------------------------------------------
no sorry, my code is in Java

have you tried using https ?
I recall having problems with http
--
To respond to this post, please click the following link:
<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4734831>
or simply reply to this email.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 6619 (20111110) __________



The message was checked by ESET NOD32 Antivirus.



http://www.eset.com

You can poke through my CUPI wrapper library for C# folks (it has more to do with providing a strongly typed object based set of functions than anything else but you can poach from there anyway). The subversion source has the library, test projects, a couple example apps using the library and there some thrilling training videos as well:

http://www.ciscounitytools.com/CodeSamples/Connection/CUPI/CUPI.html

I tend to assume when I get an error like that it's Connection fussing about the WAV file format (it's very, very fussy about it) but that's normally not a 415 I don't believe. The library above throws in the towel and I just convert EVERY wav file I send up into a format I know it likes (it's an optional flag in the wav file upload method). I got tired of it bombing on the majority of the WAVs I tried to use...

Jeff,



Your videos are very helpful, however I was hoping not to have to learn C#. I am not trying to do anything with media I am just simply trying to build a web interface to have delegated pin resets. I can do all the GET commands without any problem, but when I try to do the PUT command I get the 415 Unsupported Media error.



Thanks,



-Andy



From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, November 10, 2011 3:26 PM
To: cdicuser@developer.cisco.com
Subject: New Message from Jeff Lindborg in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: RE: New Message from Sascha Monteiro in Cisco Unity Connection Provisioning



Jeff Lindborg has created a new message in the forum "CUPI Questions":

--------------------------------------------------------------
You can poke through my CUPI wrapper library for C# folks (it has more to do with providing a strongly typed object based set of functions than anything else but you can poach from there anyway). The subversion source has the library, test projects, a couple example apps using the library and there some thrilling training videos as well:

http://www.ciscounitytools.com/CodeSamples/Connection/CUPI/CUPI.html

I tend to assume when I get an error like that it's Connection fussing about the WAV file format (it's very, very fussy about it) but that's normally not a 415 I don't believe. The library above throws in the towel and I just convert EVERY wav file I send up into a format I know it likes (it's an optional flag in the wav file upload method). I got tired of it bombing on the majority of the WAVs I tried to use...
--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4733711>

or simply reply to this email.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 6619 (20111110) __________



The message was checked by ESET NOD32 Antivirus.



http://www.eset.com

I will post my vb.net code tomorrow.

Simon



On 10 Nov 2011, at 20:57, "Cisco Developer Community Forums" <cdicuser@developer.cisco.com
> wrote:

> Andy Melick has created a new message in the forum "CUPI Questions":
> --------------------------------------------------------------
> Jeff,
>
>
>
> Your videos are very helpful, however I was hoping not to have to
> learn C#. I am not trying to do anything with media I am just simply
> trying to build a web interface to have delegated pin resets. I can
> do all the GET commands without any problem, but when I try to do
> the PUT command I get the 415 Unsupported Media error.
>
>
>
> Thanks,
>
>
>
> -Andy
>
>
>
> From: Cisco Developer Community Forums
> [mailto:cdicuser@developer.cisco.com]
> Sent: Thursday, November 10, 2011 3:26 PM
> To: cdicuser@developer.cisco.com
> Subject: New Message from Jeff Lindborg in Cisco Unity Connection
> Provisioning Interface (CUPI) - CUPI Questions: RE: New Message from
> Sascha Monteiro in Cisco Unity Connection Provisioning
>
>
>
> Jeff Lindborg has created a new message in the forum "CUPI Questions":
>
> --------------------------------------------------------------
> You can poke through my CUPI wrapper library for C# folks (it has
> more to do with providing a strongly typed object based set of
> functions than anything else but you can poach from there anyway).
> The subversion source has the library, test projects, a couple
> example apps using the library and there some thrilling training
> videos as well:
>
> http://www.ciscounitytools.com/CodeSamples/Connection/CUPI/CUPI.html
>
> I tend to assume when I get an error like that it's Connection
> fussing about the WAV file format (it's very, very fussy about it)
> but that's normally not a 415 I don't believe. The library above
> throws in the towel and I just convert EVERY wav file I send up into
> a format I know it likes (it's an optional flag in the wav file
> upload method). I got tired of it bombing on the majority of the
> WAVs I tried to use...
> --
> To respond to this post, please click the following link:
>
> <http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4733711
> >
>
> or simply reply to this email.
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 6619 (20111110) __________
>
>
>
> The message was checked by ESET NOD32 Antivirus.
>
>
>
> http://www.eset.com
> --
> To respond to this post, please click the following link:
> <http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4733755
> >
> or simply reply to this email.

Registered No. 755780 England
Registered Office: FM Insurance Company Limited
1 Windsor Dials, Windsor,
Berkshire, UK, SL4 1RS
Regulated by the Financial Services Authority.
VAT No. G.B.: 792 4276 02

Can you send the request using http and sniff the packet?  The server will respond with a 302 if you send HTTP instead of HTTPS, but it would be helpful to know the content of the HTTP headers for sure.  A 415 pretty specifically means the Content-Type or the Accept header isn't set somehow.  I've seen cases in some languages where the HTTP headers become unmodifiable, so even though they are set in the code, they don't actually get set under the covers.  A packet sniff would tell us a lot.
 
 
-Dave

I think you need to add the Content-Length header with the value of the length of sXml

XmlHttp.setRequestHeader "Content-lenght", len(sXml)

also note the setRequest, I am not sure if it's case sensitive, but if that is the case, your other headers are not set either

As promised here is the function that I use to reset the Pins (it is in VB asp.net, but should be easily ported accross)

Function resetconnectionpassword(ByVal objectid As String, ByVal ucserver As String) As String
Dim req As WebRequest
Dim rsp As WebResponse
Dim xmltxt As String
Try
req = WebRequest.Create("https://" & ucserver & "/vmrest/users/" & objectid & "/credential/pin")
req.PreAuthenticate = True
req.Method = "PUT"
Dim xmlDoc As New XmlDocument
Dim xmlWriter As XmlTextWriter
req.ContentType = "application/xml"
req.Credentials = New NetworkCredential("Username", "Password")
xmltxt = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>"
xmltxt = xmltxt & "<Credential>"
xmltxt = xmltxt & "<Credentials>90210</Credentials>"
xmltxt = xmltxt & "<CredMustChange>true</CredMustChange> "
xmltxt = xmltxt & "<Locked>false</Locked> "
xmltxt = xmltxt & "</Credential>"
' MsgBox(xmltxt)
xmlDoc.LoadXml(xmltxt)
xmlWriter = New XmlTextWriter(req.GetRequestStream(), System.Text.Encoding.UTF8)
xmlDoc.WriteTo(xmlWriter)
xmlWriter.Close()
rsp = req.GetResponse()
Catch wex As WebException
If Not wex.Response Is Nothing Then
Dim errorResponse As HttpWebResponse = Nothing
Try
errorResponse = DirectCast(wex.Response, HttpWebResponse)
Return errorResponse.StatusCode & " - " & errorResponse.StatusDescription
Finally
If Not errorResponse Is Nothing Then errorResponse.Close()
End Try
End If
End Try
Return "200"
End Function

Simon,



Do you grab the user dynamically from a search function or did you just use the code as illustrated below?



-Andy



From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Friday, November 11, 2011 4:15 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Simon Granger in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: RE: Re: New Message from Sascha Monteiro in Cisco Unity Connection Provisio



Simon Granger has created a new message in the forum "CUPI Questions":

--------------------------------------------------------------
As promised here is the function that I use to reset the Pins (it is in VB asp.net, but should be easily ported accross)

Function resetconnectionpassword(ByVal objectid As String, ByVal ucserver As String) As String
Dim req As WebRequest
Dim rsp As WebResponse
Dim xmltxt As String
Try
req = WebRequest.Create("https://" & ucserver & "/vmrest/users/" & objectid & "/credential/pin")
req.PreAuthenticate = True
req.Method = "PUT"
Dim xmlDoc As New XmlDocument
Dim xmlWriter As XmlTextWriter
req.ContentType = "application/xml"
req.Credentials = New NetworkCredential("Username", "Password")
xmltxt = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>"
xmltxt = xmltxt & "<Credential>"
xmltxt = xmltxt & "<Credentials>90210</Credentials>"
xmltxt = xmltxt & "<CredMustChange>true</CredMustChange> "
xmltxt = xmltxt & "<Locked>false</Locked> "
xmltxt = xmltxt & "</Credential>"
' MsgBox(xmltxt)
xmlDoc.LoadXml(xmltxt)
xmlWriter = New XmlTextWriter(req.GetRequestStream(), System.Text.Encoding.UTF8)
xmlDoc.WriteTo(xmlWriter)
xmlWriter.Close()
rsp = req.GetResponse()
Catch wex As WebException
If Not wex.Response Is Nothing Then
Dim errorResponse As HttpWebResponse = Nothing
Try
errorResponse = DirectCast(wex.Response, HttpWebResponse)
Return errorResponse.StatusCode & " - " & errorResponse.StatusDescription
Finally
If Not errorResponse Is Nothing Then errorResponse.Close()
End Try
End If
End Try
Return "200"
End Function
--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4735631>

or simply reply to this email.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 6619 (20111110) __________



The message was checked by ESET NOD32 Antivirus.



http://www.eset.com

I use this function to get the OBJECTID, It can either find the account by DTMFID or Alias

Function returnobjectid(ByVal ucserver As String, ByVal TelNo As String, ByVal objusername As String, ByVal searchbyusername As Boolean) As String
Try
Dim i As Integer
Dim req As WebRequest
Dim rsp As WebResponse
Dim result As String
Dim objectid As String = ""
If searchbyusername = True Then
req = WebRequest.Create("https://" & ucserver & "/vmrest/users?query=(alias%20is%20" & objusername & ")")
Else
req = WebRequest.Create("https://" & ucserver & "/vmrest/users?query=(DTMFAccessID%20is%20" & TelNo & ")")
End If
req.PreAuthenticate = True
req.Method = "get"
req.Credentials = New NetworkCredential("Username", "Password)
rsp = req.GetResponse()
Dim streamReader As New StreamReader(rsp.GetResponseStream())
result = streamReader.ReadToEnd()
streamReader.Close()
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
'Create the XML Document
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.LoadXml(result)
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/Users/User")

If m_nodelist.Count = 0 Then
Return "ZNo users mailbox found"
ElseIf m_nodelist.Count = 1 Then
'Loop through the nodes
For Each m_node In m_nodelist
For i = 0 To m_node.ChildNodes.Count - 1
'MsgBox(m_node.ChildNodes(i).Name.ToString)
If m_node.ChildNodes(i).Name.ToString.ToLower.Trim = "objectid" Then
objectid = m_node.ChildNodes.Item(i).InnerText
Exit For
End If
Next

If objectid = "" Then
Return "ZObject ID not found"
Else
Return objectid
End If
Next
Else
Return "ZTo Many Objects with the same number"
End If
m_xmld = Nothing
m_nodelist = Nothing
m_node = Nothing
Catch errorVariable As Exception
'Error trapping
Return "ZInternal Error: " & errorVariable.Message
End Try

Return "ZUnkown Error"
End Function

Simon,



Do you mind sending me your frontend page? How are you calling these functions.





From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Friday, November 11, 2011 8:09 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Simon Granger in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: RE: Re: New Message from Sascha Monteiro in Cisco Unity Connection Provisio



Simon Granger has created a new message in the forum "CUPI Questions":

--------------------------------------------------------------
I use this function to get the OBJECTID, It can either find the account by DTMFID or Alias

Function returnobjectid(ByVal ucserver As String, ByVal TelNo As String, ByVal objusername As String, ByVal searchbyusername As Boolean) As String
Try
Dim i As Integer
Dim req As WebRequest
Dim rsp As WebResponse
Dim result As String
Dim objectid As String = ""
If searchbyusername = True Then
req = WebRequest.Create("https://" & ucserver & "/vmrest/users?query=(alias%20is%20" & objusername & ")")
Else
req = WebRequest.Create("https://" & ucserver & "/vmrest/users?query=(DTMFAccessID%20is%20" & TelNo & ")")
End If
req.PreAuthenticate = True
req.Method = "get"
req.Credentials = New NetworkCredential("Username", "Password)
rsp = req.GetResponse()
Dim streamReader As New StreamReader(rsp.GetResponseStream())
result = streamReader.ReadToEnd()
streamReader.Close()
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
'Create the XML Document
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.LoadXml(result)
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/Users/User")

If m_nodelist.Count = 0 Then
Return "ZNo users mailbox found"
ElseIf m_nodelist.Count = 1 Then
'Loop through the nodes
For Each m_node In m_nodelist
For i = 0 To m_node.ChildNodes.Count - 1
'MsgBox(m_node.ChildNodes(i).Name.ToString)
If m_node.ChildNodes(i).Name.ToString.ToLower.Trim = "objectid" Then
objectid = m_node.ChildNodes.Item(i).InnerText
Exit For
End If
Next

If objectid = "" Then
Return "ZObject ID not found"
Else
Return objectid
End If
Next
Else
Return "ZTo Many Objects with the same number"
End If
m_xmld = Nothing
m_nodelist = Nothing
m_node = Nothing
Catch errorVariable As Exception
'Error trapping
Return "ZInternal Error: " & errorVariable.Message
End Try

Return "ZUnkown Error"
End Function
--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4735909>

or simply reply to this email.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 6620 (20111111) __________



The message was checked by ESET NOD32 Antivirus.



http://www.eset.com

This is for asp.net and not classic ASP

Here is the functions that run it.
(If you do not have a asp.net developer application go to www.microsoft.com/express and download Visual Web Developer It's Free)

On the ASP.Net page add a button called button1 and a textbox called textbox1 and a label called label1

then the code behind is this

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

objectid = returnobjectid("CiscoUCserver", "", textbox1.text, True)
If objectid.Substring(0, 1).ToLower = "z" Then
Label1.Text = "Update Failed: " & objectid.Substring(1, objectid.Length - 1)
Label1.ForeColor = Drawing.Color.Red
Label1.Visible = True
Return False
Else

'Reset the password
objectid = resetconnectionpassword(objectid, "CiscoUCserver")
If objectid.Length >= 3 Then
If objectid.Substring(0, 3) = "200" Then
Label1.Text = "Update Successful"
Label1.ForeColor = Drawing.Color.Black
Label1.Visible = True
Return True
Else
Label1.Text = "Update Failed: " & objectid
Label1.ForeColor = Drawing.Color.Red
Label1.Visible = True
Return False
End If
End If
End If
End Sub

You will probably have to add the reference to this at the top
 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">
Imports
</font></font><font size="2" color="#0000ff">
 
</font>
 System.IO
<font size="2" color="#0000ff"><font size="2" color="#0000ff">
Imports
</font></font><font size="2" color="#0000ff">
 
</font>
 System.Xml


 
This is for asp.net and not classic ASP

Here is the functions that run it.
(If you do not have a asp.net developer application go to www.microsoft.com/express and download Visual Web Developer It's Free)

On the ASP.Net page add a button called button1 and a textbox called textbox1 and a label called label1

then the code behind is this

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

objectid = returnobjectid("CiscoUCserver", "", textbox1.text, True)
If objectid.Substring(0, 1).ToLower = "z" Then
Label1.Text = "Update Failed: " & objectid.Substring(1, objectid.Length - 1)
Label1.ForeColor = Drawing.Color.Red
Label1.Visible = True
Return False
Else

'Reset the password
objectid = resetconnectionpassword(objectid, "CiscoUCserver")
If objectid.Length >= 3 Then
If objectid.Substring(0, 3) = "200" Then
Label1.Text = "Update Successful"
Label1.ForeColor = Drawing.Color.Black
Label1.Visible = True
Return True
Else
Label1.Text = "Update Failed: " & objectid
Label1.ForeColor = Drawing.Color.Red
Label1.Visible = True
Return False
End If
End If
End If
End Sub

It¿s not recognizing objectid? I wish I was proficient in VB.net.



From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Friday, November 11, 2011 8:42 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Simon Granger in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: RE: Re: New Message from Sascha Monteiro in Cisco Unity Connection Provisio



Simon Granger has created a new message in the forum "CUPI Questions":

--------------------------------------------------------------
You will probably have to add the reference to this at the top


<font size="2" color="#0000ff"><font size="2" color="#0000ff">
Imports
</font></font><font size="2" color="#0000ff">

</font>
System.IO
<font size="2" color="#0000ff"><font size="2" color="#0000ff">
Imports
</font></font><font size="2" color="#0000ff">

</font>
System.Xml




This is for asp.net and not classic ASP

Here is the functions that run it.
(If you do not have a asp.net developer application go to www.microsoft.com/express and download Visual Web Developer It's Free)

On the ASP.Net page add a button called button1 and a textbox called textbox1 and a label called label1

then the code behind is this

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

objectid = returnobjectid("CiscoUCserver", "", textbox1.text, True)
If objectid.Substring(0, 1).ToLower = "z" Then
Label1.Text = "Update Failed: " & objectid.Substring(1, objectid.Length - 1)
Label1.ForeColor = Drawing.Color.Red
Label1.Visible = True
Return False
Else

'Reset the password
objectid = resetconnectionpassword(objectid, "CiscoUCserver")
If objectid.Length >= 3 Then
If objectid.Substring(0, 3) = "200" Then
Label1.Text = "Update Successful"
Label1.ForeColor = Drawing.Color.Black
Label1.Visible = True
Return True
Else
Label1.Text = "Update Failed: " & objectid
Label1.ForeColor = Drawing.Color.Red
Label1.Visible = True
Return False
End If
End If
End If
End Sub


--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4735956>

or simply reply to this email.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 6620 (20111111) __________



The message was checked by ESET NOD32 Antivirus.



http://www.eset.com

Zip up what you have, attach it to the post and I will take a look (Just remember to remove all passwords)

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: 11 November 2011 13:50
To: cdicuser@developer.cisco.com
Subject: New Message from Andy Melick in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: RE: New Message from Simon Granger in Cisco Unity Connection Provisioning I

Andy Melick has created a new message in the forum "CUPI Questions":
--------------------------------------------------------------
It¿s not recognizing objectid? I wish I was proficient in VB.net.



From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Friday, November 11, 2011 8:42 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Simon Granger in Cisco Unity Connection Provisioning Interface (CUPI) - CUPI Questions: RE: Re: New Message from Sascha Monteiro in Cisco Unity Connection Provisio



Simon Granger has created a new message in the forum "CUPI Questions":

--------------------------------------------------------------
You will probably have to add the reference to this at the top


<font size="2" color="#0000ff"><font size="2" color="#0000ff">
Imports
</font></font><font size="2" color="#0000ff">

</font>
System.IO
<font size="2" color="#0000ff"><font size="2" color="#0000ff">
Imports
</font></font><font size="2" color="#0000ff">

</font>
System.Xml




This is for asp.net and not classic ASP

Here is the functions that run it.
(If you do not have a asp.net developer application go to www.microsoft.com/express and download Visual Web Developer It's Free)

On the ASP.Net page add a button called button1 and a textbox called textbox1 and a label called label1

then the code behind is this

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

objectid = returnobjectid("CiscoUCserver", "", textbox1.text, True)
If objectid.Substring(0, 1).ToLower = "z" Then
Label1.Text = "Update Failed: " & objectid.Substring(1, objectid.Length - 1)
Label1.ForeColor = Drawing.Color.Red
Label1.Visible = True
Return False
Else

'Reset the password
objectid = resetconnectionpassword(objectid, "CiscoUCserver")
If objectid.Length >= 3 Then
If objectid.Substring(0, 3) = "200" Then
Label1.Text = "Update Successful"
Label1.ForeColor = Drawing.Color.Black
Label1.Visible = True
Return True
Else
Label1.Text = "Update Failed: " & objectid
Label1.ForeColor = Drawing.Color.Red
Label1.Visible = True
Return False
End If
End If
End If
End Sub


--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4735956>

or simply reply to this email.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 6620 (20111111) __________



The message was checked by ESET NOD32 Antivirus.



http://www.eset.com
--
To respond to this post, please click the following link:
<http://developer.cisco.com/web/cupi/forums/-/message_boards/view_message/4735976>
or simply reply to this email.

________________________________
Registered No. 755780 England
Registered Office: FM Insurance Company Limited
1 Windsor Dials, Windsor,
Berkshire, UK, SL4 1RS
Regulated by the Financial Services Authority.
VAT No. G.B.: 792 4276 02

Below is my classic ASP code. I know that I am very close with this... I still get an 415 media error when I try to process it. It works perfect if I change the PUT to a GET to retrieve the object. If someone could identify what I am doing wrong it would be greatly appropriated. On the same token if someone has a completed ASP.net project they are willing to share it give me a direction to run with in that manner as well.

Thanks,

-Andy


<script language="javascript" type="text/javascript" runat="server">

function Base64Encode(input) {

var base64Key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var base64Pad = "=";
var result = "";
var length = input.length;
var i = 1;

for (i = 0; i < (length - 2); i += 3) {
result += base64Key.charAt(input.charCodeAt(i) >> 2);
result += base64Key.charAt(((input.charCodeAt(i) & 0x03) << 4) + (input.charCodeAt(i+1) >> 4));
result += base64Key.charAt(((input.charCodeAt(i+1) & 0x0f) << 2) + (input.charCodeAt(i+2)>> 6));
result += base64Key.charAt(input.charCodeAt(i+2) & 0x3f);
}

if (length%3) {
i = length - (length%3);
result += base64Key.charAt(input.charCodeAt(i) >> 2);
if ((length%3) == 2) {
result += base64Key.charAt(((input.charCodeAt(i) & 0x03) << 4) + (input.charCodeAt(i+1) >> 4));
result += base64Key.charAt((input.charCodeAt(i+1) & 0x0f) << 2);
result += base64Pad;
} else {
result += base64Key.charAt((input.charCodeAt(i) & 0x03) << 4);
result += base64Pad + base64Pad;
}
}

return result;
}
</script>

<%
sPassword = "12345"
sUserObjectId = "edb8da2b-74b4-43d4-9380-ef208f950dbd"
sUMServerToResetAgainst = "10.2.201.xx"
username = "cupiuser"
password = "xxxxxxxxxx"


Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")

objXML.Open "PUT", "http://" & sUMServerToResetAgainst & "/vmrest/users/" & sUserObjectId & "/credential/pin", False, "cupiuser", "xxxxxxxxxx"
objXML.setRequestHeader "Authorization", "Basic " & Base64Encode(username & ":" & password)
objXML.setRequestHeader "ContentType", "application/xml"
objXML.setRequestHeader "Content-lenght", len(sXml)
objXML.setOption(2) = 13056

'On Error Resume Next

xmltxt = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>"
xmltxt = xmltxt & "<Credential>"
xmltxt = xmltxt & "<Credentials>90210</Credentials>"
xmltxt = xmltxt & "<CredMustChange>true</CredMustChange> "
xmltxt = xmltxt & "<Locked>false</Locked> "
xmltxt = xmltxt & "</Credential>"



objXML.send xmltxt




ResponseXml = objXML.ResponseText
Response.ContentType = "application/xml"
response.write responseXML
%>

Hi Andy -

I encountered this same issue when working on this for our internal tools. I got it working by breaking the request into two separate requests. In the first PUT request, I set the parameters and then set the password or PIN. However, the format of the XML that is required is slighyly different. Try this:

First request, send

xmltxt = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>"
xmltxt = xmltxt & "<Password>"
xmltxt = xmltxt & "<CredMustChange>true</CredMustChange> "
xmltxt = xmltxt & "<Locked>false</Locked> "
xmltxt = xmltxt & "</Password>"

Then send a second request to the same URI with:

xmltxt = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>"
xmltxt = xmltxt & "<Password>"
xmltxt = xmltxt & "<Credentials>90210</Credentials>"
xmltxt = xmltxt & "</Password>"

Hopefully this will work for you.

- David

Ryan,

What do you mean by CredentialType? Did you pass this as a RequestHeader?

-Andy

This is what i meant. update your PUT xml payload.

sXml=sXml & "<Credential>"
sXml=sXml & " <Credentials>44444</Credentials>"
sXml=sXml & " <CredentialType>4</CredentialType>"
sXml=sXml & "</Credential>"