Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

POST returning 403 in custom object

Anonymous
Not applicable

I'm using a Rest API call to create a content record in our Archer environment. This works for me when I run it from my local machine but returns a 403 error when I try to run the same code from a custom object. I've been unable to troubleshoot thus far. Any hep would be fantastic.

 

Thanks,
Eric

 

var settings5 = {
'url':'GENERICURL/FOLDER/api/core/system/content',
'method':'POST',
'headers': {
'Accept': 'application/json,text/html,application/xhtml+xml,application/xml;q =0.9,*/*;q=0.8',
'Content-Type': 'application/json',
'Authorization': 'Archer session-id=' + sessionToken,
},
'body': "{ \"Content\": { \"LevelId\":\"393\",\"FieldConents\": {} } }\r\n"
}

$.ajax(settings5).done(function (response) {
console.log(response);
1 ACCEPTED SOLUTION

Accepted Solutions

Hmm, you're sending the call as a POST and not sure why the REST API thinks it's a GET.

 

I typically use the following when creating records:

$.ajax({
     type: "POST",
     url: baseURL+'/api/core/content/',
     data: JSON.stringify(attachmentContent),
     contentType: 'application/json',
     headers: {
          'x-csrf-token': (window.sessionStorage) ? window.sessionStorage.getItem("x-csrf-token") : parent.parent.ArcherApp.globals['xCsrfToken']
     },
     processData: false,
     dataType: 'json',
     success: function(data, textStatus, jqXHR) {},
     error: function(jqXHR, textStatus, errorThrown) {}
});

 Advisory Consultant

View solution in original post

5 REPLIES 5

DavidPetty
Archer Employee
Archer Employee

Eric, add the following to the header of the request:

'x-csrf-token': (window.sessionStorage) ? window.sessionStorage.getItem("x-csrf-token") : parent.parent.ArcherApp.globals['xCsrfToken']

 Advisory Consultant

Anonymous
Not applicable

That got me to a 400 (BadRequest)

 

<Error>
<Message>
The requested resource does not support http method 'GET'.
</Message>
</Error>
The rabbit hole continues.

Hmm, you're sending the call as a POST and not sure why the REST API thinks it's a GET.

 

I typically use the following when creating records:

$.ajax({
     type: "POST",
     url: baseURL+'/api/core/content/',
     data: JSON.stringify(attachmentContent),
     contentType: 'application/json',
     headers: {
          'x-csrf-token': (window.sessionStorage) ? window.sessionStorage.getItem("x-csrf-token") : parent.parent.ArcherApp.globals['xCsrfToken']
     },
     processData: false,
     dataType: 'json',
     success: function(data, textStatus, jqXHR) {},
     error: function(jqXHR, textStatus, errorThrown) {}
});

 Advisory Consultant

Anonymous
Not applicable

When I use that ajax call specifically within the custom object it worked as expected. I'll tinker a bit more to see if I can figure out what the difference is but thanks for you timely help.

My pleasure Eric

 Advisory Consultant