I'm trying to use DataMiner API to create a job via HTTP. I'm using Postman to test this.
After running the ConnectApp call, I'm trying to use the CreatJob call. I'm sending the following body in the HTTP Post:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CreateJob xmlns="http://www.skyline.be/api/v1">
<connection>{{connection}}</connection>
<domainID>5ea15997-7995-41db-926c-624d4bf5ca8e</domainID>
<job>
<ID>bc5f2b9a-85d6-4017-865f-d8e4456bdb2d</ID>
<Name>{{job-name}}</Name>
<TimeStartUTC>{{start-time}}</TimeStartUTC>
<TimeEndUTC>{{end-time}}</TimeEndUTC>
<Sections>
<DMAJobSection>
<ID>8724a340-6157-4b06-979d-57f9e4b411ab</ID>
<SectionDefinitionID>8724a340-6157-4b06-979d-57f9e4b411ab</SectionDefinitionID>
<Name>DefaultSectionDefinitionExtension</Name>
<Type>string</Type>
<Fields xsi:nil="true">
</Fields>/>
</DMAJobSection>
</Sections>
</job>
</CreateJob>
</soap12:Body>
</soap12:Envelope>
And for this, I'm getting the following response:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Skyline.DataMiner.Web.Common.WebApiException: The default job section is required.
at Skyline.DataMiner.Web.Common.v1.JobsModule.ExecuteCRUDAction[T](CRUDAction`1 action)
at Skyline.DataMiner.Web.Common.v1.JobsModule.CreateJob(String connection, DMAJob jobNew)
at Skyline.DataMiner.Web.v1.Json.<>c__DisplayClass388_0.<CreateJob>b__0()
at Skyline.DataMiner.Web.WAF.Engine.ValidateAndRun[T](String connection, Func`1 function, String interfaceName, String methodName, String[] argumentNames, Object[] argumentValues)
at Skyline.DataMiner.Web.v1.Json.CreateJob(String connection, String domainID, DMAJob job)
--- End of inner exception stack trace ---
I thought that the default job section data (job name, start and end time) were valid (bc5f2b9a-85d6-4017-865f-d8e4456bdb2d is the GUID from the default job section).
Can someone shed some light how to proceed?
Additionally, I couldn't find in DataMiner help information about the Fields tag, so I not sure how to pass a field value to DatMiner.
EDIT:
After trying Wale's approach, I'm having another error: "bruno test-postman is missing some sections that are defined on the job domain."
I think my three sections are present in my request, please let me know what I'm missing to have a successful create job call.
HTTP Request body:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CreateJob xmlns="http://www.skyline.be/api/v1">
<connection>{{connection}}</connection>
<domainID>5ea15997-7995-41db-926c-624d4bf5ca8e</domainID>
<job>
<Sections>
<DMAJobSection>
<SectionDefinitionID>bc5f2b9a-85d6-4017-865f-d8e4456bdb2d</SectionDefinitionID>
<Name>DefaultJobSection</Name>
<Fields>
<DMAJobFieldValueDisplay>
<ID>ab725528-df04-4798-ba1b-b9635a47c58b</ID>
<Name>Name</Name>
<Value>{{job-name}}</Value>
<Type>Text</Type>
</DMAJobFieldValueDisplay>
<DMAJobFieldValueDisplay>
<ID>e47a1a1d-abf7-4572-b05e-80976e81b8d6</ID>
<Name>Start Time</Name>
<Value>{{start-time}}</Value>
<Type>DateTime</Type>
</DMAJobFieldValueDisplay>
<DMAJobFieldValueDisplay>
<ID>daf59475-c03d-480d-8aef-23fc43c4a247</ID>
<Name>End Time</Name>
<Value>{{end-time}}</Value>
<Type>DateTime</Type>
</DMAJobFieldValueDisplay>
</Fields>
</DMAJobSection>
<DMAJobSection>
<ID>8724a340-6157-4b06-979d-57f9e4b411ab</ID>
<SectionDefinitionID>8724a340-6157-4b06-979d-57f9e4b411ab</SectionDefinitionID>
<Name>DefaultSectionDefinitionExtension</Name>
<Type>string</Type>
<Fields xsi:nil="true">
<DMAJobFieldValueDisplay>
<ID>a7e1a37a-203c-4074-8009-f4d9f12fd5f6</ID>
<Name>FieldDescriptorName: Service Definition Name</Name>
<Value>[MAIN] RF SAT IRD to SDI</Value>
<Type>GenericEnum`1</Type>
</DMAJobFieldValueDisplay>
</Fields>/>
</DMAJobSection>
<DMAJobSection>
<ID>c8c22f36-f436-4f08-8a8c-ff301639e342</ID>
<SectionDefinitionID>c8c22f36-f436-4f08-8a8c-ff301639e342</SectionDefinitionID>
<Name>Bookings</Name>
<Type>string</Type>
<Fields xsi:nil="true">
</Fields>
</DMAJobSection>
</Sections>
</job>
</CreateJob>
</soap12:Body>
</soap12:Envelope>
Section definitions (client test tool screenshot):
So in order to make this call work, you will need to adjust a few things:
When you add fields in the default section, the api will create a new custom section in the database where it will store the extended fields.
That's the "DefaultSectionDefinitionExtension" that you see in your client test screenshot.
When creating a CreateJob call however, you don't need to separate these fields from the default section.
You can just add the extended fields in the default section and the API will acknowledge that and put it in the correct section.
The typing of the extended dropdown field was incorrect.
The string values that we support for Type are the following:
(Text, Email, Url, Checkbox, User, Integer, Double, AutoIncrement, DateTime, TimeSpan, Dropdown and StaticText(but the last one is a special one))
Last point should actually not matter that much for a CreateJob call but for sake of completeness i'll include it.
DMAJobSection also has a Type property which can be either "job-field-section" or "job-booking-section" depending on whether the SectionDefinition has ReservationLinkInfo or not.
So to summarize:
- Remove the DMAJobSection of the extended section
- Add the Extended field in the default section
- Update the field type from GenericEnum1 to Dropdown
- Add <Type>job-field-section</Type> to the default section
- Add <Type>job-booking-section</Type> to the booking section