I’m having trouble connecting to the BigCommerce API using JavaScript in Zapier. Every time I try to make a request, I get a 401 unauthorized error and I can’t figure out what’s wrong.
Here’s the code I’m using:
var credentials = 'Basic ############';
var endpoint = 'https://store-*****.mybigcommerce.com/api/v2/products?name=test****';
$.ajax({
url: endpoint,
type: 'GET',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
async: false,
crossDomain: true,
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', credentials);
},
success: function(data) {
alert('success');
console.log(data);
},
error: function(xhr, status, error) {
console.log(xhr.responseText);
console.log(status);
console.log(error);
}
});
I keep getting the same 401 unauthorized response no matter what I try. I’ve tested this on secure HTTPS pages but still no luck. Has anyone dealt with this before? Any help would be awesome.
Had the same frustration with BigCommerce API calls through Zapier. You’re probably base64 encoding your credentials wrong or the string format’s off. Your Basic auth string needs Basic followed by base64(username:password), but BigCommerce actually uses base64(username:api_key). Check that your API user has the right permissions in your store admin - specifically product read access. The v2 API you’re using has been deprecated for ages, which might explain the auth issues. I ditched the custom JavaScript and switched to Zapier’s built-in BigCommerce integration - fixed all the auth headaches instantly.
This is a CORS preflight issue with BigCommerce’s API. When you use crossDomain: true, Zapier sends an OPTIONS request first, and BigCommerce v2 endpoints usually reject it before your GET request even runs. I hit this same problem three months ago and wasted hours thinking it was auth when it wasn’t. Just remove the crossDomain parameter - let Zapier handle cross-origin stuff on its own. Also, your endpoint URL looks like it might be hitting rate limits or has bad query parameters. BigCommerce is super picky about URL encoding when searching product names. Test with a basic products endpoint first (no query params) to figure out if it’s auth or request formatting causing the 401.
check if zapier is populating your credentials var correctly. sometimes it just doesn’t pass the auth data right, which leads to empty or messed headers. log that var before your request - it’ll show what’s actually being sent.
I had this exact issue last month. It was my authentication headers in Zapier’s environment. You’re probably mixing auth methods or your credentials aren’t passing through Zapier’s JavaScript step correctly. Switch to the v3 REST API with X-Auth-Token and X-Auth-Client headers instead of Basic auth with the legacy v2 API. Check that your API credentials have the right permissions for the products resource you’re accessing. My store hash in the URL was different than expected, so verify that matches your actual store identifier. The async: false parameter can break things in Zapier’s environment - just remove that line.
Classic Zapier auth problem. Zapier’s JavaScript environment handles API credentials differently than regular web requests, so your Basic auth string is getting mangled or encoded wrong.
I’ve hit this same issue tons of times with BigCommerce. Instead of fighting Zapier’s JavaScript quirks, try Latenode - it connects to BigCommerce natively without the auth nightmare.
Just migrated a similar workflow from Zapier to Latenode. Authentication works immediately, no manual Basic auth headers or credential juggling. Better error handling too, and you can swap API versions easily.
The visual builder beats debugging JavaScript in Zapier’s cramped environment.
Check it out: https://latenode.com