-
- Novice
- Posts: 8
- Liked: never
- Joined: Dec 09, 2013 7:20 pm
- Full Name: Tim O'Callaghan
Cloning Jobs
Hi! Long time listener, first time caller.
I just have a quick question. Or at the very least I hope it's quick.
I'm using php curl to talk with the Veeam API, and for the life of me I can't seem to successfully send a POST request to clone a job. My question isn't so much how to do it with PHP, but what would the following error tell you in response to my post request?
<snip>
<?xml version="1.0" encoding="utf-8"?>
<Error Message="Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CloneJob' 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." StatusCode="500"
.....
</snip>
I've verified that I'm posting to the correct url (http://myveeamapi:9399/api/jobs/c174aaa ... tion=clone) and that the xml is valid and a string.
$tmp = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
"<JobCloneSpec 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\">".
"<BackupJobCloneInfo>".
"<JobName>Job Name</JobName>".
"<FolderName>Testing Folder</FolderName>".
"<RepositoryUid>urn:veeam:Repository:67a8ed9d-c81f-4643-84cb-da735a4230fd</RepositoryUid>".
"</BackupJobCloneInfo>".
"</JobCloneSpec>";
Ive also made sure that I've added both Content-Type: text/xml; encoding='utf-8' and Content-Length: strlen($post_body) to the post headers but continually get a 500 in return.
Any help, even if it's just with the error message would be really appreciated.
I just have a quick question. Or at the very least I hope it's quick.
I'm using php curl to talk with the Veeam API, and for the life of me I can't seem to successfully send a POST request to clone a job. My question isn't so much how to do it with PHP, but what would the following error tell you in response to my post request?
<snip>
<?xml version="1.0" encoding="utf-8"?>
<Error Message="Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CloneJob' 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." StatusCode="500"
.....
</snip>
I've verified that I'm posting to the correct url (http://myveeamapi:9399/api/jobs/c174aaa ... tion=clone) and that the xml is valid and a string.
$tmp = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
"<JobCloneSpec 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\">".
"<BackupJobCloneInfo>".
"<JobName>Job Name</JobName>".
"<FolderName>Testing Folder</FolderName>".
"<RepositoryUid>urn:veeam:Repository:67a8ed9d-c81f-4643-84cb-da735a4230fd</RepositoryUid>".
"</BackupJobCloneInfo>".
"</JobCloneSpec>";
Ive also made sure that I've added both Content-Type: text/xml; encoding='utf-8' and Content-Length: strlen($post_body) to the post headers but continually get a 500 in return.
Any help, even if it's just with the error message would be really appreciated.
-
- VP, Product Management
- Posts: 27377
- Liked: 2800 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Cloning Jobs
Hi Tim,
1. I think you can try to put this XML in the body of the POST query of our client (http://localhost:9399/web) to see the output. I don't have a lab right now to check it myself.
2. Also I would suggest reviewing some examples right here - EM install path>\samples. For all XSD examples there are stubs generated, might give a clue on what's wrong.
3. If nothing above helps, you can try to do the following:
• Uncomment the following section in this config file - Veeam.Backup.Enterprise.RestAPIService.exe.config
• Restart Veeam RESTApi service
• Call a clone job function
• Review this file - WcfDetailTrace.e2e using this tool > http://msdn.microsoft.com/en-us/library/ms732023.aspx
Let me know if that helps!
1. I think you can try to put this XML in the body of the POST query of our client (http://localhost:9399/web) to see the output. I don't have a lab right now to check it myself.
2. Also I would suggest reviewing some examples right here - EM install path>\samples. For all XSD examples there are stubs generated, might give a clue on what's wrong.
3. If nothing above helps, you can try to do the following:
• Uncomment the following section in this config file - Veeam.Backup.Enterprise.RestAPIService.exe.config
Code: Select all
<system.diagnostics>
<trace autoflush="true">
</trace>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="WcfDetailTrace.e2e" />
</listeners>
</source>
</sources>
</system.diagnostics>
• Call a clone job function
• Review this file - WcfDetailTrace.e2e using this tool > http://msdn.microsoft.com/en-us/library/ms732023.aspx
Let me know if that helps!
-
- Lurker
- Posts: 1
- Liked: never
- Joined: Nov 29, 2011 7:12 pm
- Full Name: Luke
- Contact:
Re: Cloning Jobs
Hi Tim,
You have faced this issue because you did not include this header "X-RestSvcSessionId" which is mandatory in the request. You should get it in response to a login request.
Thanks!
You have faced this issue because you did not include this header "X-RestSvcSessionId" which is mandatory in the request. You should get it in response to a login request.
Thanks!
-
- Novice
- Posts: 8
- Liked: never
- Joined: Dec 09, 2013 7:20 pm
- Full Name: Tim O'Callaghan
Re: Cloning Jobs
Thanks for responding.
So it turns out it was the way I was building the HTTPHEADERS using PHP Curl. What was happening was I was setting the headers twice. Once with the content-type/length and then re-setting with the X-RestSvcSessionId token. The fix was to set put all HTTPHEADERS into an array (yes, like the PHP CURL documentation specifies) and set only once! So the de-serialization error makes total sense because I was overwriting the content-type: application/xml with the X-RestSvcSessionId. It was a huge oversight on my part. But finally worked it out!
Again, thank you very much for responding.
So it turns out it was the way I was building the HTTPHEADERS using PHP Curl. What was happening was I was setting the headers twice. Once with the content-type/length and then re-setting with the X-RestSvcSessionId token. The fix was to set put all HTTPHEADERS into an array (yes, like the PHP CURL documentation specifies) and set only once! So the de-serialization error makes total sense because I was overwriting the content-type: application/xml with the X-RestSvcSessionId. It was a huge oversight on my part. But finally worked it out!
Again, thank you very much for responding.
-
- VP, Product Management
- Posts: 27377
- Liked: 2800 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Cloning Jobs
Tim, thank you for updating the topic with the resolution.
Who is online
Users browsing this forum: No registered users and 2 guests