Retrieving Bills works from GraphiQL tool but not from a custom application based on WebClient

To Whom It May Concern:

We have a WebClient based application which retrieves our ShipHero data. It submits queries and processes the returned GraphQL objects extracting all required data. The application works perfectly with all data collections like Products, Orders, Shipments, etc. with exceptions of Bills. The Bills query call does not fail but it always returns just the empty result.
When debugging the application we grabbed the query string submitted by the application and pasted it into the GraphiQL client and there the same query works perfectly returning the expected result. The same result is when going the opposite way: Cutting the successful query from GraphiQL and pasting it into the application which submits it to the ShipHero API which then returns an empty result.

The used query string:
{
bills(from_date: “2021-10-03T00:00”, to_date: “2021-12-04T00:00”) {
data(first: 10) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
legacy_id
status
customer_name
profile_name
created_at
due_date
amount
totals(first: 10) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
legacy_id
amount
label
category
quantity
}
}
}
}
}
}
}
}

The result produced by GraphiQL:
{
“data”: {
“bills”: {
“data”: {
“pageInfo”: {
“hasNextPage”: true,
“endCursor”: “YXJyYXljb25uZWN0aW9uOjk=”
},
“edges”: [
{
“node”: {
“id”: “QmlsbDozNTk2Mw==”,
“legacy_id”: 35963,
“status”: “paid”,
“customer_name”: “CurlKalon”,
“profile_name”: “UWS-CK”,
“created_at”: “2021-05-07T18:47:04”,
“due_date”: “2021-06-02”,
“amount”: “509.56”,
“totals”: {
“pageInfo”: {
“hasNextPage”: false,
“endCursor”: “YXJyYXljb25uZWN0aW9uOjA=”
},
“edges”: [
{
“node”: {
“id”: “RmVlQ2F0ZWdvcnlUb3RhbDoxMDU1NDE=”,
“legacy_id”: 105541,
“amount”: “509.56”,
“label”: null,
“category”: “order”,
“quantity”: 85
}
}
]
}
}
},

The result produced by the application when submitting exactly the same query string:

{“data”:{“bills”:{“data”:{“pageInfo”:{“hasNextPage”:false,“endCursor”:null},“edges”:}}}}

As an experienced developer I first looked for bugs in my code. However, I found none and the fact that the code works as designed without a single glitch with all other queries strongly implies that there must be some difference between Bills collection and other data. Nevertheless, it does not explain why the same query string works perfectly from GraphiQL and not from the WebClient.

Any help or suggestion with this issue would be greatly appreciated.

Martin Vanha

Hello @martin!
Welcome to the ShipHero Public API community.
Do you think you could get me a request ID from a query done manually and another one from the query done through the application? This would allow me to trace the calls better.
You can get those by adding the field request_id inside bills at the same level as data
Have a nice day!
TomasFD

Hello Tomas,
Thanks for your prompt response!

Here are the data you requested:

This is the query used for both GraphiQL and WebClient application:
{
bills {
request_id
data(first: 1) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
legacy_id
status
customer_name
profile_name
created_at
due_date
amount
totals(first: 10) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
legacy_id
amount
label
category
quantity
}
}
}
}
}
}
}
}

Result from the GraphiQL:

{
“data”: {
“bills”: {
“request_id”: “61b288f83e4880a4c40f2be3”,
“data”: {
“pageInfo”: {
“hasNextPage”: true,
“endCursor”: “YXJyYXljb25uZWN0aW9uOjA=”
},
“edges”: [
{
“node”: {
“id”: “QmlsbDozNTk2Mw==”,
“legacy_id”: 35963,
“status”: “paid”,
“customer_name”: “CurlKalon”,
“profile_name”: “UWS-CK”,
“created_at”: “2021-05-07T18:47:04”,
“due_date”: “2021-06-02”,
“amount”: “509.56”,
“totals”: {
“pageInfo”: {
“hasNextPage”: false,
“endCursor”: “YXJyYXljb25uZWN0aW9uOjA=”
},
“edges”: [
{
“node”: {
“id”: “RmVlQ2F0ZWdvcnlUb3RhbDoxMDU1NDE=”,
“legacy_id”: 105541,
“amount”: “509.56”,
“label”: null,
“category”: “order”,
“quantity”: 85
}
}
]
}
}
}
]
}
}
}
}

Running from the application:

{“data”:{“bills”:{“request_id”:“61b28849b712b9a28c5cf8a2”,“data”:{“pageInfo”:{“hasNextPage”:false,“endCursor”:null},“edges”:}}}}

Please let me know whatever else you need to know.

Sincerely
Martin

Hello @martin!
Thank you for sharing that.
I will dive deeper into this and reach out to you when I have an update
Have a nice day!
tomasFD

Hello Thomas,
I have an update on our problem. I was working on refreshing the authorization token for our application and while debugging I noticed the ShipHero’s response:

{“access_token”:“eyJhbGciOi…1wbBg-4p9imGqR7OiBnjXeKuUkrispR_Q2ZD7Q8SW0FkSaGHGdF-kXrEoo5wPyolYW2o5x0vp8l3rN69Ys7w”,“expires_in”:2419200,“scope”:“openid profile view:products change:products view:orders change:orders view:purchase_orders change:purchase_orders view:shipments change:shipments view:returns change:returns view:warehouse_products change:warehouse_products view:picking_stats view:packing_stats offline_access”,“token_type”:“Bearer”}

After the end of the access token is the expiration time and after that the “scope”. The scope contains a few collections like products, orders, shipments, and so on. Apparently bills are not listed in the scope. I am not certain what the inclusion in the scope means but I suspect that it might be the problem why the application cannot access bills while the GraphiQL can. I believe that the authorization in the GraphiQL was done with a different token than the application. Could you please let me know how to add the Bills to the scope or whatever should be changed or configured on our side.
Thanks again for your help!
Martin

Hey @martin!
Thank you for sharing this last piece of information.

I compared both queries using the Request IDs you sent me last week, and I see you are using different users for the app (OS) and the manual testing (Gavin). However, both have the same scope.

Is there a chance you could try using the application’s token within the GraphQL client? Or the other way around, whichever you prefer. So we can rule out if its account related.

Have a nice day!
TomasFD

Hello Tomas,
I have the result of a test you suggested:
I used the refresh token used by our application and I performed a refresh wia CURL. I received the new token which I imported to GraphiQL. It now behaves the same way as the application meaning that it works for everything else except the Bills. Here is the result with the request id:
{
“data”: {
“bills”: {
“request_id”: “61ba78a840ccbdd3c1478ad9”,
“complexity”: 101,
“data”: {
“pageInfo”: {
“hasNextPage”: false
},
“edges”:
}
}
}
}

After that I configured the GraphiQL back with the original token (Gavin) and the bills query works as is supposed to:
{
“data”: {
“bills”: {
“request_id”: “61ba7b4f249911813556bb40”,
“complexity”: 101,
“data”: {
“pageInfo”: {
“hasNextPage”: true
},
“edges”: [
{
“node”: {
“id”: “QmlsbDozNTk2Mw==”,
“legacy_id”: 35963,
“status”: “paid”,
“customer_name”: “CurlKalon”,
“profile_name”: “UWS-CK”,
“created_at”: “2021-05-07T18:47:04”,
“due_date”: “2021-06-02”,
“amount”: “509.56”,
“totals”: {
“pageInfo”: {
“hasNextPage”: false
},
“edges”: [
{
“node”: {
“id”: “RmVlQ2F0ZWdvcnlUb3RhbDoxMDU1NDE=”,
“legacy_id”: 105541,
“amount”: “509.56”,
“label”: null,
“category”: “order”,
“quantity”: 85
}
}
]
}
}
},

Hello Tomas,
I have to apologize that I made sort of a mess with this “ticket”. The same day I posted the message on the ShipHero Community I also sent an email to ShipHero CS. I got a response from Monica stating that she opened the ticket and asked me for some additional info. However, then I got an email from you so I assumed that you are working on that ticket and I was responding to you and neglected the other email from Monica. I just received her email that the ticket is inactive and she is going to close it. So my question is if it is possible somehow to merge these two “tickets” into one. It really is the same issue.
I hope that the last info I sent you yesterday would help to solve it. It seems to me clear that the problem is connected to the token. When one works and the other doesn’t.
Please let me know,
Martin

Hey @martin!
Thank you for trying that out, and it seems to be related to the user then. If I’m correct, Gavin is a full user, and OS is just a dev one, right? Would you please confirm this?
As for the ticket, I will get in touch with Monica or provide the ticket number. I cannot merge them, but I can add a hidden comment in this post with the link to quickly consult if necessary.
Kind regards,
TomasFD

Hello Tomas,
My boss Gavin confirmed that you are correct. He has the full user. I haven’t tried using his account in the application. I’ll try it next.
Martin