Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2018-09-17 04:17 PM
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
2018-09-18 09:23 AM
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
2018-09-17 04:22 PM
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
2018-09-17 04:58 PM
That got me to a 400 (BadRequest)
2018-09-18 09:23 AM
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
2018-09-18 02:38 PM
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.
2018-09-18 02:42 PM
My pleasure Eric
Advisory Consultant