+1

API | Create a classic project: body code | log files

Juan (Comunica Translations) 2 years ago in API updated 2 years ago 1

Hello:

I am trying to create my first Classic Project with the API and I keep getting the answe 415: Unsupported Media Type.

I assume this error comes due to a non-valid body sent to the endpoint: https://server/home-api/projects.

The thing is that I cannot figure out what's missing or what is not in the right format.
Before implementing the POST call in my code, I am trying to send the request with Postman, and this is the body that I am sending:

{
"customerID": 108,
"serviceID": 27,
"specializationId": 37,
"sourceLanguageId": 73,
"targetLanguagesIds": [84],
"name": "First project create from API",
"categoriesIds": [],
"inputFiles": [],
"dates": {
"startDate": {
    "value": 1680403200
},
"deadline": {
   "value": 1680613200
},
"actualStartDate": {
   "value": 1680403200
},
"actualDeliveryDate": {
   "value":1680510000
}
},
"instructions": {
   "forCustomer": "",
   "forProvider": "",
   "internal": "",
   "paymentNoteForCustomer": "",
   "paymentNoteForVendor": "",
   "notes": ""
},
"people": {
   "responsiblePersons": {
      "projectManagerId": 21,
      "projectCoordinatorId": 21
   },
   "customerContacts": {
      "primaryId": 0,
      "SendBackToId": 0,
      "additionalIds": []
   }
}
}

Can anyone see a missing part or an invalid input?
I followed the schema shown in: https://comunicadk.s.xtrf.eu/api-doc#/home-api

Another question would be that I don't seem to find the log that will tell me which is the exact issue with the request. Is there actually one?

Thanks a lot for your help.
My best regards.

Found out what the problem was. 

In postman, you can choose the body's format, I chose: Raw-> JSON, and that, gave me an error that was pointing out to the property "dates" structure.

This is the correct one:

"dates": {
    "startDate": {
      "time": 1680403200
    },
    "deadline": {
      "time": 1680613200
    },
    "actualStartDate": {
      "time": 1680403200
    },
    "actualDeliveryDate": {
       "time": 1680510000
    }
}

It wasn't "value" but "time" the property that will set the dates.