Edit credentials description

RESTful knowledge exchange

Edit credentials description

Veeam Logoby Mardock » Fri Jul 25, 2014 8:02 am

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.
Mardock
Influencer
 
Posts: 19
Liked: never
Joined: Thu Jul 10, 2014 3:40 pm

Re: Edit credentials description

Veeam Logoby poulpreben » Fri Jul 25, 2014 8:05 am

Hi Mardock,

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

Cheers,
Preben
poulpreben
Expert
 
Posts: 935
Liked: 398 times
Joined: Mon Jul 23, 2012 8:16 am
Full Name: Preben Berg

Re: Edit credentials description

Veeam Logoby v.Eremin » Fri Jul 25, 2014 8:28 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Edit credentials description

Veeam Logoby poulpreben » Fri Jul 25, 2014 8:35 am

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>
poulpreben
Expert
 
Posts: 935
Liked: 398 times
Joined: Mon Jul 23, 2012 8:16 am
Full Name: Preben Berg

Re: Edit credentials description

Veeam Logoby Mardock » Fri Jul 25, 2014 10:14 am

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.
Mardock
Influencer
 
Posts: 19
Liked: never
Joined: Thu Jul 10, 2014 3:40 pm

Re: Edit credentials description

Veeam Logoby poulpreben » Fri Jul 25, 2014 10:17 am

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
poulpreben
Expert
 
Posts: 935
Liked: 398 times
Joined: Mon Jul 23, 2012 8:16 am
Full Name: Preben Berg

Re: Edit credentials description

Veeam Logoby Mardock » Fri Jul 25, 2014 10:35 am

Yes, in my request headers there are:

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

Thank you,
Mardock
Mardock
Influencer
 
Posts: 19
Liked: never
Joined: Thu Jul 10, 2014 3:40 pm

Re: Edit credentials description

Veeam Logoby v.Eremin » Mon Jul 28, 2014 9:51 am

Might it be that you're setting headers two times, instead of one? Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to RESTful API



Who is online

Users browsing this forum: No registered users and 2 guests