NoMethodError on client.orders.retrieve_order

this works in the API explorer but not when I run it from my own machine… straight copy & paste

result = client.orders.retrieve_order(
  order_id: "8y2LbMmLpof8DAzWzD4fH8teV"
)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

I get the following errors:
{:category=>“INVALID_REQUEST_ERROR”, :code=>“NOT_FOUND”, :detail=>“Resource not found.”}

NoMethodError (undefined method `retrieve_order’ for #Square::OrdersApi:0x00007f97d6cd19f8):

Are you running this in the same directory that you have SDK configured to? This error normally happens when the SDK isn’t accessible which is why your getting the not found error. :slightly_smiling_face:

Yes, I’m running other requests in the same method successfully,

labor API, team API, payments API

I just tested with this exact code and an order_id from my account and it worked as expected. The only way I could replicate this was by removing the file from the directory. Have you looked at the file path? Maybe try to hard code it to see if that gets it working? :slightly_smiling_face:

So I’m using the ruby gem square.rb

I’m getting the error message on any request that I try using the orders.api… Again I’m not having any issues with things like team.search_team_members, payments.list_payments, labor.search_shifts

all of these requests are happening in the same method

I’ve tried
batch_retrieve_orders
search_orders
retrieve_order

{:category=>“INVALID_REQUEST_ERROR”, :code=>“NOT_FOUND”, :detail=>“Resource not found.”}

If you create a new file and try:

require 'square'

client = Square::Client.new(
  access_token: ENV.fetch('SQUARE_ACCESS_TOKEN'),
  environment: 'production',
  timeout: 1
)

result = client.orders.retrieve_order(
  order_id: "8y2LbMmLpof8DAzWzD4fH8teV"
)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Does it work or are you getting the same error? This one’s tough to troubleshoot since you have other calls working. :slightly_smiling_face:

created a new file … new directory, still getting the same error

quickstart.rb:1:in `': uninitialized constant Square (NameError)

I am wondering if this is related to my ruby version. I’m using 2.6.10 not 2.7

The SDK supports 2.6 through 3.1 so I’m not sure what’s going on. Especially since other API calls are succeeding. Would you mind reaching out to this link so we can setup some time to debug. :slightly_smiling_face: