RESTful knowledge exchange
Post Reply
Mardock
Influencer
Posts: 23
Liked: never
Joined: Jul 10, 2014 3:40 pm
Contact:

Edit credentials description

Post by Mardock »

Hi,
I'm trying to edit credentials description. I make HTTP PUT request but the server response is 500 internal server error.

This is my example request:

Code: Select all

Request:
PUT http://<Enterprise-Manager>:9399/api/backupServers/{ID_bckupServer}/credentials/{ID_credentials}

Request Header:
X-RestSvcSessionId NDRjZmJkYmUtNWE5NS00MTU2LTg4NjctOTFmMDY5YjdjMmNj

Request Body:
<?xml version="1.0" encoding="utf-8"?>
<CredentialsInfo Href="http://localhost:9399/api/backupServers/f62624c1-8462-4747-8bd4-d686f35b0540/credentials/9a8fb453-cacd-4089-a97e-437e99f128bc" Type="Credentials" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Id>9a8fb453-cacd-4089-a97e-437e99f128bc</Id>
	<Description>Edited via RESTful API</Description>
</CredentialsInfo>

Response:
500 Internal server error.
Thank you,
Mardock.
poulpreben
Certified Trainer
Posts: 1024
Liked: 448 times
Joined: Jul 23, 2012 8:16 am
Full Name: Preben Berg
Contact:

Re: Edit credentials description

Post by poulpreben »

Hi Mardock,

Did you try to make a POST request instead of PUT?

Cheers,
Preben
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Edit credentials description

Post by veremin »

As far as I'm aware, it should be PUT method. I've just edited the credentials, using the following body request, and everything seems to have worked properly. So, feel free to try it:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<CredentialsInfo Type="Credentials" Href="http://localhost:9399/api/backupServers/{ID}/credentials/{ID}" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Id>{ID}</Id>
  <Username>{NAME}</Username>
  <Description>Edited via RestAPI</Description>
  <Password/>
</CredentialsInfo>
Thanks.
poulpreben
Certified Trainer
Posts: 1024
Liked: 448 times
Joined: Jul 23, 2012 8:16 am
Full Name: Preben Berg
Contact:

Re: Edit credentials description

Post by poulpreben »

You are right. It also works without <Username> and <Password/> tags as OP suggested:

Code: Select all

<?xml version="1.0" ?>
<CredentialsInfo Href="http://10.0.0.5:9399/api/backupServers/25fa85fe-df49-42f5-b289-f1b2fd69961c/credentials/5968272a-3c63-409d-ae3c-fe013794df93" Type="Credentials" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Id>5968272a-3c63-409d-ae3c-fe013794df93</Id>
	<Description>no user, no pass</Description>
</CredentialsInfo>
Mardock
Influencer
Posts: 23
Liked: never
Joined: Jul 10, 2014 3:40 pm
Contact:

Re: Edit credentials description

Post by Mardock »

Hi,
The request doesn't work yet...

If I sniff the HTTP traffic I get in the body of response the following error :

Code: Select all

Unable to deserialize XML body with root name 'CredentialsInfo' and root namespace 'http://www.veem.com/ent/v1.0' (for operation 'EditCredentials' and contract ('IEnterpriseRestService',  'http://www.veeam.com/ent/v1.0')) using XmlSerializer. Ensure that the type corresponding to the XML is added to the known types collection of the service.
Thank you very much,
Mardock.
poulpreben
Certified Trainer
Posts: 1024
Liked: 448 times
Joined: Jul 23, 2012 8:16 am
Full Name: Preben Berg
Contact:

Re: Edit credentials description

Post by poulpreben »

Is "Content-Type: text/xml" in your request headers as well?

Here is an example using Python Requests: https://www.dropbox.com/s/8d5tflshe1hyy ... ription.py
Mardock
Influencer
Posts: 23
Liked: never
Joined: Jul 10, 2014 3:40 pm
Contact:

Re: Edit credentials description

Post by Mardock »

Yes, in my request headers there are:

Content-Type: text/xml;
Host: veeamserver:9398
Content-Length: 479
Expect: 100-continue

Thank you,
Mardock
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Edit credentials description

Post by veremin »

Might it be that you're setting headers two times, instead of one? Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests