Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json object not passed to GoogleApi.post call #35

Open
brandflownet opened this issue Feb 9, 2016 · 0 comments
Open

Json object not passed to GoogleApi.post call #35

brandflownet opened this issue Feb 9, 2016 · 0 comments

Comments

@brandflownet
Copy link

I am trying to make POST call towards Search Console API. I got my example running under API Explorer, however when I try to make the same call from my meteor project, I am getting error:

Object {error: Object} error: Object code: 400 errors: Array[1] message: "Parse Error"
My code:

function fetchSEOForWebsite(website) {

    var call = 'webmasters/v3/sites/' + 'mdbootstrap.com' + '/searchAnalytics/query'
    var params = {
        "searchType": "web",
        "dimensions": [
            "query",
            "date",
            "page"
        ],
        "startDate": "2016-02-06",
        "endDate": "2016-02-08"
    }


    GoogleApi.post(call, {
        params: params
    }, function(error, answer) {

        console.log(answer);

    });
}

From Chrome console I can see POST payload:

searchType=web&dimensions=query%2Cdate%2Cpage&startDate=2016-02-06&endDate=2016-02-08

The same query works perfectly fine from API Explorer :


POST https://www.googleapis.com/webmasters/v3/sites/http%3A%2F%2Fmdbootstrap.com/searchAnalytics/query?key={YOUR_API_KEY}

{
 "searchType": "web",
 "dimensions": [
  "query",
  "date",
  "page"
 ],
 "startDate": "2016-02-06",
 "endDate": "2016-02-08"
}

I also checked paylod sent via API Explorer and it's different:

{ "searchType": "web", "dimensions": ["query","date","page"
], "startDate": "2016-02-06", "endDate": "2016-02-08" }

So it looks like for some reason my params are not passed as a JSON object to call...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant