GET HTTP 404 error while trying to access MarketPlace endpoint

Hi! So I am trying to access this endpoint here:

https://developer.github.com/v3/apps/marketplace/#check-if-a-github-account-is-associated-with-any-marketplace-listing

Basically, I would like to check whether or not a user is actively subscribed to one of the my app’s plans.

But unfortunately, I keep on receiving this as an error message: “Octokit::NotFound - GET https://api.github.com/marketplace_listing/accounts/123456: 404 - Not Found // See: https://developer.github.com/v3/apps/marketplace/#check-if-a-github-account-is-associated-with-any-marketplace-listing:”

I’m coding in Ruby, using the official Octokit library. Here’s my code:

def marketplace_listing
      #random account id
      account_id = 123456
      authenticate_app
      endpoint = "/marketplace_listing/accounts/#{account_id}"
      stubbed_endpoint = "/marketplace_listing/stubbed/accounts/#{account_id}"

      results = @app_client.get(endpoint) # Returns 404 Not Found error.
end


def authenticate_app
payload = {
          # The time that this JWT was issued, _i.e._ now.
          iat: Time.now.to_i,

          # JWT expiration time (10 minute maximum)
          exp: Time.now.to_i + (10 * 60),

          # Your GitHub App's identifier number
          iss: APP_IDENTIFIER
      }

      # Cryptographically sign the JWT.
      jwt = JWT.encode(payload, PRIVATE_KEY, 'RS256')

      # Create the Octokit client, using the JWT as the auth token.
      accept = 'application/vnd.github.machine-man-preview+json'
      headers = { 'Accept' => accept}
      @app_client = Octokit::Client.new(bearer_token: jwt, headers: headers)
end

I’ve tried replacing the endpoint with the stubbed endpoint, and it works fine. 

The documentation mentioned that requests that require authentication will return 404 Not Found, but I don’t know exactly is wrong.

If I’m understanding correctly what you’re doing, the documentation states also that you’ll get a 404 Not Found when the account has not purchased the listing. Given that you’re using a random account ID, I would assume that the random account ID has not purchased your listing and 404 would be the expected response.

Let me know if I’ve misunderstood.

2 Likes

That was the problem. Thank you!