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 Issue with API Results and Excessive Token Consumption
Dear Moz Support Team, I hope this message finds you well. I am writing to express my concerns regarding the performance of the Moz API, which I have been using for domain information retrieval through Zapier. Despite paying for your API service, I am encountering several significant issues that are affecting my ability to use the service effectively: Incorrect and Inconsistent Data: When I query domain information, I receive incorrect results for Page Authority (PA), Domain Authority (DA), and Spam Score (SS). Specifically, PA and DA are always returned as 1, while SS is consistently -1, which indicates that the data being provided is either incomplete or incorrect. This discrepancy is preventing me from relying on your service for accurate domain insights. Excessive Token Consumption: I have noticed that the API token usage is significantly higher than expected. After querying only 250 domains, my token consumption has already exceeded 6,000 tokens, which seems unusually high. I had understood that the token usage would be calculated per query, but it appears that the consumption is much higher than anticipated. Given that I have invested in this service, I am frustrated that I am not receiving the expected level of performance and data accuracy. Could you please investigate these issues and provide clarity on why this is happening? Additionally, I would appreciate any guidance on how to resolve these discrepancies and ensure that I am using the API in the most efficient way possible. I look forward to your prompt response and assistance in resolving these issues. thank you
Product Support | | tkddh13230 -
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 -
Why Moz Giving Error, Permission Denied in Excel Sheets
I am Using Moz Pro just Installed Moz Addon in Google excel Sheets integrated properly with keys. But when I put Links for Bulk DA PA and Hit the Get Data within few seconds it says Error! Permission denied. Even My URLS are below 200 Links always giving this error. Any other way to use Moz API for Bulk DA PA Checking
API | | Umair1233213 -
Error Code 803
Hello all, With every new Moz report that comes in, an error code 803 appears. I check each link that comes up as an 803 but they work perfectly. What could be causing this to happen? Error Code 803: Incomplete HTTP Response Received Your page did not send a complete response to the Moz Crawler's request. Our crawler is pretty standard, so it's likely that other browsers and crawlers may also encounter this error. If you have this error on your homepage, it prevents the Moz crawler (and some search engines) from crawling the rest of your site.
API | | moon-boots0 -
Error with the MozBar
Hi Mozzers I am geting this very annoying message keeps popping up "Confirm Oops! Something went wrong while trying to get your API Credentials. Please try again or check out the Help Hub if you are still experiencing issues" Issue is I cant even read it on my screen as it gets cut off and there is no scroll so had to copy and past into word to be able to read it. I had the issue for the last sever hours, is this my account or more general. Thanks Andy
API | | Andy-Halliday0 -
Huge in crease in on page errors
Hi guys I’ve just checked my online campaign and I see errors in my crawl diagnostics have almost doubled from the 21<sup>st</sup> of October to the 25<sup>th</sup> of October going from 6708 errors to 11 599. Can anyone tell me what may have caused this? Also I notice we have a lot of issues with duplicate page titles which seems strange as no new pages have been added, can anyone explain why this might be? I look forward to hearing from you
API | | Hardley1110 -
Batch URL Error 413
Hello, i am using the free mozscape api to get the domain and page authority of urls. i am batching the url as shown in the sample code however i have over 500 URL i need to check and when running the request i get the following: stdClass Object ( [status] => 413 [error_message] => Too many urls in batch. Batches must be less than or equal to 200 urls. ) When i change it to 200 urls the request works fine, now is there a way to enable me to batch all 500 urls at once? i did read that the beta api is capable of batching urls in one request : http://moz.com/blog/400-higher-throughput-mozscape-api-now-in-beta-and-seeking-testers Has this been implemented yet into the current api? Thanks
API | | pauledwards0