Hi All
I encountered an error trying to perform a POST command with a request body input as a String type,
<Error Message="Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' and contract ('IEnterpriseRestService', 'http://www.veeam.com/ent/v1.0')) using XmlSerializer.
Is there any specific format to be used to post the XML body? Can we just define the XML body as a string value and use it as input for the POST command? Will it work that way?
Can advise.
Thanks.
Regards
Alim.
-
- Novice
- Posts: 5
- Liked: never
- Joined: Mar 11, 2012 5:49 am
- Full Name: Mohammad Alim
- Contact:
-
- Novice
- Posts: 5
- Liked: never
- Joined: Mar 11, 2012 5:49 am
- Full Name: Mohammad Alim
- Contact:
Re: Format for POST request body
Additional info with regards to the above, i am trying to use VMware Orchestrator (vco) to automate adding the VM to the job.
Workflow script
var requestContent = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<CreateObjectInJobSpec 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\">" +
"<HierarchyObjRef>urn:VMware:VM:5a12aea1-e48f-4bc5-85cd-59a8444a4acf.vm-645</HierarchyObjRef>" +
"<HierarchyObjName>backupclient1</HierarchyObjName>" +
"<Order>0</Order>" +
"<GuestProcessingOptions>" +
"<AppAwareProcessingMode>RequireSuccess</AppAwareProcessingMode>" +
"<FileSystemIndexingMode>ExceptSpecifiedFolders</FileSystemIndexingMode>" +
"<IncludedIndexingFolders/>" +
"<ExcludedIndexingFolders>" +
"<Path>%windir%</Path>" +
"<Path>%ProgramFiles%</Path>" +
"<Path>%TEMP%</Path>" +
"</ExcludedIndexingFolders>" +
"<CredentialsId/>" +
"</GuestProcessingOptions>" +
"</CreateObjectInJobSpec>";
var requestType = "POST";
var operationUrl = ""/jobs/aae2a6b-d3af-4b0c-b5fc-6b9c45206eeb/includes"
var request = restHost.createRequest(requestType, operationUrl, requestContent);
Error message
2015-04-13 11:00:10.089] <?xml version="1.0" encoding="utf-8"?><Error Message="Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' 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" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instan ... age>Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' 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.</FirstChanceExceptionMessage><StackTrace>Veeam.Backup.Interaction.RestAPI.CRestAPICommunicationException: Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' 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. ---> System.Runtime.Serialization.SerializationException: Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' 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.
at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.ReadObject(Message message)
at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
at Veeam.Backup.Enterprise.RestAPIService.FormsPostDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
--- End of inner exception stack trace ---</StackTrace></Error>
Workflow script
var requestContent = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<CreateObjectInJobSpec 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\">" +
"<HierarchyObjRef>urn:VMware:VM:5a12aea1-e48f-4bc5-85cd-59a8444a4acf.vm-645</HierarchyObjRef>" +
"<HierarchyObjName>backupclient1</HierarchyObjName>" +
"<Order>0</Order>" +
"<GuestProcessingOptions>" +
"<AppAwareProcessingMode>RequireSuccess</AppAwareProcessingMode>" +
"<FileSystemIndexingMode>ExceptSpecifiedFolders</FileSystemIndexingMode>" +
"<IncludedIndexingFolders/>" +
"<ExcludedIndexingFolders>" +
"<Path>%windir%</Path>" +
"<Path>%ProgramFiles%</Path>" +
"<Path>%TEMP%</Path>" +
"</ExcludedIndexingFolders>" +
"<CredentialsId/>" +
"</GuestProcessingOptions>" +
"</CreateObjectInJobSpec>";
var requestType = "POST";
var operationUrl = ""/jobs/aae2a6b-d3af-4b0c-b5fc-6b9c45206eeb/includes"
var request = restHost.createRequest(requestType, operationUrl, requestContent);
Error message
2015-04-13 11:00:10.089] <?xml version="1.0" encoding="utf-8"?><Error Message="Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' 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" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instan ... age>Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' 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.</FirstChanceExceptionMessage><StackTrace>Veeam.Backup.Interaction.RestAPI.CRestAPICommunicationException: Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' 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. ---> System.Runtime.Serialization.SerializationException: Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'CreateObjectInJob' 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.
at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.ReadObject(Message message)
at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
at Veeam.Backup.Enterprise.RestAPIService.FormsPostDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
--- End of inner exception stack trace ---</StackTrace></Error>
-
- Service Provider
- Posts: 14
- Liked: 1 time
- Joined: Mar 20, 2015 3:45 pm
- Full Name: Joel Neutzner
- Location: Switzerland
- Contact:
Re: Format for POST request body
Did you specify the ContentType-header? Take a look at the "must-have"-headers here: http://helpcenter.veeam.com/backup/80/rest/
-
- Novice
- Posts: 5
- Liked: never
- Joined: Mar 11, 2012 5:49 am
- Full Name: Mohammad Alim
- Contact:
Re: Format for POST request body
Yes, the header has been specified as "Content-Type" and "application/xml".
Thanks.
Thanks.
-
- Novice
- Posts: 5
- Liked: never
- Joined: Mar 11, 2012 5:49 am
- Full Name: Mohammad Alim
- Contact:
Re: Format for POST request body
I used my own script to post the header instead of the built-in script, and it works now. Thanks.greenhoorn wrote:Did you specify the ContentType-header? Take a look at the "must-have"-headers here: http://helpcenter.veeam.com/backup/80/rest/
Who is online
Users browsing this forum: No registered users and 3 guests