client.OrdersApi.SearchOrdersAsync returning nothing?

The following code if copied from the API Explorer. I want to get the transactions (like i do from the square mobile app) in my POS program.

While we have sales showing up in the square mobile transactions screen,
As you can see API Explorer is returning {}. The location Id is our production location but I changed it for this illustration. What might be wrong? the API logs say 200 OK but where are the transactions? The transactions API is said to be depreciated in favor of the orders API.

var locationIds = new List();
locationIds.Add(“LQ1234567890”);

var query = new SearchOrdersQuery.Builder()
.Build();

var body = new SearchOrdersRequest.Builder()
.LocationIds(locationIds)
.Query(query)
.Limit(10)
.ReturnEntries(true)
.Build();

try
{
var result = await client.OrdersApi.SearchOrdersAsync(body: body);
}
catch (ApiException e)
{
Console.WriteLine(“Failed to make the request”);
Console.WriteLine($“Response Code: {e.ResponseCode}”);
Console.WriteLine($“Exception: {e.Message}”);
}

Response 200

cache-control: max-age=0, private, must-revalidate
content-length: 3
content-type: application/json; charset=utf-8
date: Fri, 03 Dec 2021 21:39:19 GMT
square-version: 2021-11-17

{}

:wave: What’s the location_id that you are passing in so I can check the logs? :slightly_smiling_face:

LQG0TTX8ESC1E

Thank you.

Looking at that account there hasn’t been any orders or payments taken with it. That’s the reason you’re getting the {} response which is expected. :slightly_smiling_face:

I’m confused then.

If I login not as me the developer where all the apps are but as the seller login, then I can see the transactions. My App is integrated with it (it has access token permissions). So I guess I need the location Id of that seller account not the location Id for the App as I provided and returns {}. I went poking around the seller dashboard but saw no location Id. - can you direct me as to where it might be found.? I should be on my way then. :+1>

I see that CreateTerminalCheckout will return a location_id. Perhaps that will be the one I want maybe.

I’m not sure I fully understand the question. The CreateTerminalCheckout currently won’t create on order till the checkout is paid for. There still aren’t any API calls to the Orders API or fully paid payment on the account which is why there isn’t any results in the SearchOrders request.

Also the only way to get the location_id is to either call ListLocations with our APIs or to get the location_id from the Locations section in your credentials on the Developer Dashboard. :slightly_smiling_face:

And that is where I got the location_id that returnith nothing.

My wife owns two square accounts for two different companies at the same physical location. I have a Square Oauth App for both but am only using one now that I have the terminal working.

They both have the same location_id and only one of the two accounts has the transactions (Herbal Fracture) - maybe this is causing ambiguity in the API call. and it’s picking the account that has no transactions to speak of. - How do I correct that so that I only have 1 location_id?

You’ll need to get the location_id and the correct access token for the account that has the transactions. Currently the one you provided doesn’t have any payments. :slightly_smiling_face:

When I pair my terminal I get back among other things, a location_id.
Lo and behold, that location Id is different that the one I posted earlier that was empty. This one is G8F5QKTQN6D2Z.

I thought, Ah Ha! now it’s going to work. Only to get an 401 UNAuthorized error. - using the same token that the daily transactions that are performed at the terminal.

Are you using the same access token that was associated to the other account? If so you will need to make sure you’re using the access token that is associated to the account with location_id: G8F5QKTQN6D2Z . :slightly_smiling_face:

Yeah I know their a duo and need to go together. And yes as stated, the access token is the same one used at the terminal that makes the transactions. I don’t know if it’s cricket to DM you the token or not but I will if its is ok practices.

1 Like

If you ListLocations with the access token you have does the location_id: G8F5QKTQN6D2Z get returned?

Hold my beer er… coffee.

NO!

What the heck? only LQG0TTX8ESC1E!

However, when I pair the terminal I get back the deviceID which is correct
(it’s the serial # of the unit) and location_id: G8F5QKTQN6D2Z. And this terminal is selling product the the sales are going into the square account like we expect.

I obviously don’t understand something.

Not sure what’s going on with the devices but you will need to get an access token that returns that location_id in order to see the payments for the account. :slightly_smiling_face:

I’m just gonna give up for your sake. Go help people with real problems. I’ll just use my phone app to check transactions as I always have done. I thought it would be nice to have it all in the POS system but it’s not necessary.

If you are able to get the access token for that account then you will be able to pull in all the sales. That appears to be your only blocker. Do you have access to the Developer Dashboard for that account?

What a face-palm :roll_eyes:

In APIExplorer I was choosing the token that was associated with the production app. I guess I was lazily thinking that was our current token.
Our token is in an encrypted state on the db so I had to decrypt it to see it
and yeah, it’s different than the one I can pick for the production app, and when I use it and the G8F5QKTQN6D2Z location_id I get our transactions
like I want.

Dum A$$…

Sorry to waste y’alls time.

Glad to hear you figured it out. :slightly_smiling_face: