esriRequest returnes "415 Unsupported media type" with js aspi 4.12

629
1
07-16-2019 03:16 AM
deleted-user-OOe4JK-9Abnm
New Contributor III

Hi,

After update form 4.11 to 4.12 posting of data stopped to work.

export const postActivityLog = (activityDTO: ActivityLogDTO): Promise<any> => {
return new Promise((resolve, reject) => {
esriRequest(`${activityAPI}/activityLog`, {
method: 'post',
responseType: 'json',
query: JSON.stringify(activityDTO),
}).then((result: any) => {
resolve(result.data);
}).catch(error => {
reject(error);
});
});
};

This code worked correct in 4.11, see image.

With 4.12 I get:

Status Code: 415 Unsupported Media Type
Content-Type: application/problem+json; charset=utf-8
Form data:
    1. 0:
      {
    2. 1:
      "
    3. 2:
      a
    4. 3:
      c
    5. 4:
      t
    6. 5:
      i
    7. 6:
      v
    8. 7:
      i
    9. 8:
      t
    10. 9:
      y
    11. 10:
      I
    12. 11:
      d and so on...
See image with Network log.JS API 4.11. Works correct!
JS API 4.12 Does not work!
0 Kudos
1 Reply
Noah-Sager
Esri Regular Contributor

It looks like the query is being assigned to a string instead of an object. I think you could try setting the body to a string, or pass an object to the query. Hope this helps!

0 Kudos