Search code examples
ruby-on-railsrubyinstagraminstagram-api

instagram public media fetch 404 error


Getting very strange issue same Instagram API was working from last few months and now it stops working for two days and it's through 404 error, below is the code:

INSTA_BASE_WEB_URL = "https://www.instagram.com"
INSTA_BASE_URL = "https://api.instagram.com"

def get_public_images username, params
      endpoint = "#{username}/media"
      http_response = HTTParty.get("#{INSTA_BASE_WEB_URL}/#{endpoint}", query: params)
      if http_response&.code == 200
        begin
          return JSON.parse(http_response.body)
        rescue
        end
      end
      return nil
    end

Solution

  • Did you check if there were changes in the API ? From what I understand in https://www.instagram.com/developer/endpoints/users/#get_users_media_recent, the endpoint should be :

    https://api.instagram.com/v1/users/{user-id}/media/recent/?access_token=ACCESS-TOKEN