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 Feature to add to my site to give people a domain score for their own site
Looking to add a feature on my website to invite people to submit their domain to get an SEO score (and a report). How do I do that? I think it involves the Moz API but not sure.
API | | mikeymosh0 -
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 -
API url_metrics Error deserializing POST body
Getting error in https://lsapi.seomoz.com/v2/url_metrics API I'm using Basic Auth for authentication. { "name": "Bad Request", "message": "Error deserializing POST body"} CVW2T4f
API | | verdet32321 -
MOZscape API Signup "An unknown error has occurred"
Hello, I am not able to signup for MOZscape API, I am getting error while signing up for MOZScape API under free trial. https://moz.com/checkout/api --> Getting error here, please help. Thanks.
API | | rahul2k11in0 -
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 -
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 -
Duplicate description error: one for meta one for og:type
I am getting the duplicate description error from Moz. I use both the og:description and . I am not sure if that is going to get me penalized by the search engines or my pages somehow discounted if I have meta description and og:description on the same page. What does Moz recommend? NOTE: for years I have followed this in the best practices format put out from other sources. Found at: http://webmasters.stackexchange.com/questions/52600/should-i-have-ogdescription-and-meta-description-together-on-every-page Short Answer: Use both! Long Answer: The OG stands for Open Graph which is apart of the Open Graph protocol of which works on platforms such as Facebook. The meta description element is for search engines such as Google, Yahoo and Bing. Since these are two separate tags that kinda do the same thing but they are designed for different types of platforms, one for Facebook and the other for Search Engines. The reasoning behind this is that the Open Graph protocal is more rich in what content can be feed to Facebook without scrapping the full page, think rich snippets. So images, description and more information is feed to Facebook via the Open Graph. Using both is a good idea.
API | | jessential0