making ajax post requests : 400 error?

making ajax post requests : 400 error?

aidendev
Shopify Partner
12 0 0

I'm leveraging .NET Razor pages for my proxy applications, and so i have been able to successfully leverage jquery to make GET requests from my Razor View to my Razor backend.
However, I have yet to figure out how this is done for POST requests without getting a 400 error.
the structure of my ajax calls are generally as such:
$.ajax({
type: 'POST',
url: '/apps/proxyappname?handler=UpdateInfo',
data: JSON.stringify(formData),
contentType: 'application/json',
dataType: 'json',
success: function (response) {
console.log("Update successful:", response);
},
error: function (xhr, status, error) {

console.log("XHR:", xhr);
console.log("Status:", status);
console.log("Response Text:", xhr.responseText);
}
});

is there something that has to be passed in addition? Thank you guys

Reply 1 (1)

aidendev
Shopify Partner
12 0 0

so update: with more digging I see that we have to pass the Access token of the proxy application
I did so by passing it with the Bearer prefix, and can confirm that it is showing up in the Network's Header tab with Dev Tools:
" Authorization: Bearer access_token_value "

nonetheless, I am getting the 400 bad request. Any Shopify Developers working with .NET know about this?