Help

Connecting to Moz API

Topic Labels: Scripting extentions
1144 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Kosta_Kondraten
7 - App Architect
7 - App Architect

Hi,

I signed up for your API yesterday to access from my AirTable - and I’m writing some scripting language stuff and having difficulty accessing it. I’m not sure if the issue is my authorisation or something else.

Any input you could give would be much appreciated.

Here is the AirTable script code:

const mozUser = “mozscape-7955101d0e”;

const mozPass = “940e510b81cc5cac3081080d1c63a653”;

let response = await remoteFetchAsync(‘https://lsapi.seomoz.com/v2/url_metrics’, {

method: ‘POST’,

headers: {

‘Content-Type’: ‘application/json’,

‘Authorization’: ‘Basic bW96c2NhcGUtNzk1NTEwMWQwZTo5NDBlNTEwYjgxY2M1Y2FjMzA4MTA4MGQxYzYzYTY1Mw==’ // this is me doing an encode 64 on the values above

},

“targets”: [“moz.com”]

});

console.log(response);

Here is the response:

image

If you have any input on how I could do a basic request for some data just as a proof of concept to actually have JSON returned on any of the functions (as they all have the same result for me) - it would be much appreciated.

This is the fetch script:

This is the video of me attempting to connect through AirTable:

Thank you!

1 Reply 1
lee-on_pedahzur
4 - Data Explorer
4 - Data Explorer

Not sure if you solved this already, but you need to stringify the request body:

let response = await remoteFetchAsync(‘https://lsapi.seomoz.com/v2/url_metrics’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: ‘Basic ${encoded key and secret}’
},
body:JSON.stringify({“targets”: [“moz.com”]}
});

Also, very bad idea to post your credentials. I hope you deleted them and that no one abused them on your behalf