Unsolved url_metrics - Error deserializing POST body
-
Hi,
I'm trying to reproduce this Postman url_metrics request in Google Apps Script (GAS) :
But in GAS, I get this error :
I suspect it's the body (line 90) that causes the issue, but can't figure out how to fix it.
Any suggestion ?
-
Hello, try to use this way it will work:
$username='Access ID'; $password='Secret Key'; $URL='https://lsapi.seomoz.com/v2/url_metrics'; $payload = json_encode(array("targets" => ["moz.com"])); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$URL); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); $result=curl_exec ($ch); $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code curl_close ($ch); print_r(json_decode($result, true));
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Unsolved Empty Response from API v1
Hi, I always receive a empty reponse from your API v1. Here ist my API call for further investigation:
API | | George4445
"http://lsapi.seomoz.com/linkscape/url-metrics/https://www.moz.com/?AccessID=mozscape-1234567890&Expires=1719916530&Signature=generatedsignaturecode" Reponse: {} Do you experience some problems with the api? Thank you very much
Regards George Shaylen0 -
Unsolved "The account does not have access to that quota" - API v1 URL Metrics
Hi! On one of our servers we get the message "The account does not have access to that quota" when pulling data for v1 URL Metrics endpoint in the API.
API | | aheitzman
This only happens on one specific server, others have worked flawlessly. Any idea of what might be going on? Thanks0 -
Unsolved MOZ API to Google Data Studio
Dopes MOZ have anything like this? https://www.semrush.com/features/google-data-studio-connector/
Product Support | | WebMarkets0 -
Unsolved Can I get Moz keywords via API?
Hi, my boss is asking if you "have any API for keyword research -- e.g., as soon as a user creates a card title in [our application], we can auto-recommend keywords from Moz within [the application]. I shared a link with him to your Links API page, but he says he doesn't think that API does the above. Can you help? Thank you, Renae
API | | CarolinaRen0 -
Crawl error HELP!
Hi. I have two campaigns that are constantly giving crawl errors, but in Search Console I don't. How can I do to fix this? The URLs are: https://www.starmeup.com/blog/en/ and https://www.starmeup.com/blog/es/ Thanks
API | | lala20172 -
MOZ API - metadata permission error
Hi there, I have a small issue using MOZ API. I cannot make successful GET request for metadata (index stats). The request looks like this: http://lsapi.seomoz.com/linkscape/metadata/index_stats?AccessID=mozscape-XXXXXX&Expires=1497442682&Signature=XXXXXX. In my most recent request, I got an error message: "Permission denied: pckgmhkomakbnflgmckhobiiojjmomjpph". Did I forget something? Signed Authentication should be OK, because it works with other endpoints, such as "url-metrics", "links" etc. Thanks in advance! Kind regards, Zoran
API | | Databox-apps1 -
Moz Crawl: Can't check page optimization error https
Help needed, when I try to do a page optimization check i get the following error : The URL you entered does not appear to be returning a page successfully. Please make sure that you've entered the URL of valid, working page. But i can do a site crawl, what should be the problem? Checked with frog seo spider and add no problem, robots.txt its also clean. Anyone knows what can be wrong? Thanks
API | | Luis-Pereira0