question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createApiRequest encodes url, resulting in 404 for pubsub endpoints

See original GitHub issue

I’m trying to pull() a subscription using pubsub.projects.subscriptions.pull()

const pubsub = google.pubsub('v1');
const request = {
    subscription: 'projects/project-1235/subscriptions/my-subscription',
    auth: oAuthClient,
    resource: {
        maxMessages: 1,
        returnImmediately: true,
    },
};

pubsub.projects.subscriptions.pull(request, cb);

But it results in a 404.

I looked around and apparently it is because this line here encodes the URI and forward slashes become %2F and google doesn’t recognise it.

This is probably required for other requests so i’m not quite sure what the fix would be.

Currently I’m creating the request myself and calling it with authClient.request(). If anyone else is stuck with this, here’s my temporary fix:

const project = 'my-project-12345';
const subscription = 'my-subscription';

const pullReq = {
    url: `https://pubsub.googleapis.com/v1/projects/${project}/subscriptions/${subscription}:pull`,
    method: 'POST',
    paramsSerializer: params =>
        qs.stringify(params, { arrayFormat: 'repeat' }), // qs = require('qs')
    params: {
        maxMessages: 1,
        returnImmediately: true,
    },
    maxContentLength: 2147483648,
    validateStatus: status =>
        (status >= 200 && status < 300) || status === 304,
};

oAuthClient.request(pullReq).then(response => { ...

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JustinBeckwithcommented, Apr 2, 2018

Apologies for the trouble folks “It seemed like a good idea time” (™). Taking a look now.

0reactions
tomnewtoncommented, Apr 17, 2018

it is affecting a ton of apis. Looks like a fix is almost there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Api is giving 404 when added + as part of URL (%2B)
+ is a special character. It should ideally be should be URL encoded as %2B . Turns out it's not really required though...
Read more >
tomnewton - Profile - Bountysource
tomnewton commented on this issueFixing image encoding format conversion. ... this issuecreateApiRequest encodes url, resulting in 404 for pubsub endpoints.
Read more >
googleapis documentation
A token which can be passed to a subsequent call to the ListEndpoints method to retrieve the next page of results in ListEndpointsRequest.pageToken....
Read more >
Viewing online file analysis results for 'hackfor32bit.exe'
This website uses cookies to enhance your browsing experience. Please note that by continuing to use this site you consent to the terms...
Read more >
Google APIs Client Library for Node.js - GitHub Pages
Accelerated Mobile Pages (AMP) URL API * * This API contains a single method, batchGet. ... @example * var google = require('googleapis'); *...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found