Expected API Response - Delete All Users
I'm updating the sharpy client to include promotions (coupon
codes).
https://github.com/SeanOC/sharpy
(original)
https://github.com/SmartFile/sharpy
(updates)
I'm trying to get the unit test to work. I'm having a little
trouble with expected results from the api. The first question was
on a bad request.
https://cheddargetter.com/xml/plans/productCode/SHARPY_UNIT_TESTS
This now returns a 404. However the unittests act like they expect
it to return a 400. Obviously it is missing the /get
part of the url. A 404 seems valid to me. Did this change from a
400 to a 404 at some point in the last 4 years?
The second thing is deleting all customers. The unit tests use
this method between tests to clean up.
https://cheddargetter.com/xml/customers/delete-all/confirm/[current
unix timestamp]/productCode/SHARPY_UNIT_TESTS
Obviously, current time stamp is filled in when I call it. The
response simply says user
. I'm not sure if that one
word response means I have an issue. This seems like an issue on
the cheddar side because it isn't an xml response. It also does not
delete all customers.
Do I need to update something in the settings to make delete all
customers work on a development account? What is the expected
response for delete all customers api endpoint?
https://cheddargetter.com/developers#delete-all-customers
Ryan Johnston
SmartFile
Discussions are closed to public comments.
If you need help with Cheddar please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Marc Guyer on 25 Aug, 2015 06:27 PM
I honestly can't be sure. Based on my knowledge of our routing, I don't see how that could possibly be anything but a 404. We don't have any special routing for
plans/get
so that would literally meanplans
controller andproductCode
action which doesn't exist.I just ran a test of this and I'm unable to confirm. This endpoint behaves as expected. Do you happen to have the raw response logged for this? I suspect that there's something else in play...
No
As usual, it's a 200 status. The body is
2 Posted by Ryan Johnston on 25 Aug, 2015 06:51 PM
Agreed, there probably is something else at play here. I'm definitely only getting
user
as the response. I get the same result in the browser and in my code.Here is a browser request.
Request Headers
Response Headers
BodyIn the Python code:
It's using Basic Authentication.url
Response Headers
BodySupport Staff 3 Posted by Marc Guyer on 25 Aug, 2015 07:52 PM
That is very strange. I'm still unable to replicate that -- browser or curl, I always get the expected response.
Here's something: I was combing our web logs and found that your requests appear to always be of the strict 401/200 variety. According to spec, the request is supposed to be sent without auth, then when the 401 response is received, the request is resent with the auth header. That procedure makes it possible for the client to analyze the response headers and determine the best method of auth. Most http libs recognize that the auth params have already been provided and so they're sent in the original request, avoiding the need for the second request. That goes against spec but it's clearly more efficient and most often the desired behavior. Httplib2 does it the strict way. We know that the auth method is basic so there's no need for the double round-trip. You can force httplib2 to include the auth header in the initial request but I don't recall the recommended way. On the most basic level, you could just build the auth header and add it to the request directly. Httplib2 might have a more convenient way of doing that.
I don't have any evidence of that being the problem here. I suggest doing the workaround anyway and see if you get different behavior. That would at least give us something to go on.
4 Posted by Ryan Johnston on 25 Aug, 2015 08:00 PM
Can you give me the curl request (without your credentials of course)? I'm interested in seeing if I can get the correct xml back and work backwords.
I am using httplib2. I'm pretty sure I am forcing it to include the auth in the initial request.
Support Staff 5 Posted by Marc Guyer on 25 Aug, 2015 08:09 PM
Even though it has the auth params, it insists on getting the 401 before it will resend with the auth header. You have to workaround that. Here's an example where the header is built and given to the request method:
https://josephscott.org/archives/2011/06/http-basic-auth-with-httpl...
Curl doesn't do the 401 thing. You can force it to with the --anyauth flag if you want. Here it is without:
6 Posted by Ryan Johnston on 25 Aug, 2015 08:29 PM
It hates me. Even with curl.
I guess we can rule out CHED01VMW01 vs CHED01VMW02. Now I've hit both of them.
Support Staff 7 Posted by Marc Guyer on 25 Aug, 2015 08:34 PM
Can you confirm from a different network?
8 Posted by Ryan Johnston on 25 Aug, 2015 08:44 PM
Here is the same curl request from a different machine in Florida:
9 Posted by Ryan Johnston on 25 Aug, 2015 08:52 PM
Here is another one from a server over at IUPUI:
Thanks for all your help on this.
10 Posted by Ryan Johnston on 25 Aug, 2015 09:18 PM
Trying some different things with another developer here we have determined that you can put whatever you want after the delete-all and get the same result:
user
Also, if you tell it to return
json
instead ofxml
, it will still returnuser
.Bad password tries to redirect to login (302). So, it gets past authentication when it returns
user
.Support Staff 11 Posted by Marc Guyer on 26 Aug, 2015 01:18 PM
It's beginning to look like the problem is specific to your account. I'd like to run some tests against your SHARPY_UNIT_TESTS account. Do I have your permission to do that?
This is expected. There is no JSON context for this action so it behaves like a UI request. You'll find that if you use the wrong auth with the
/xml/
route, you'll get the expected 401.12 Posted by Ryan Johnston on 26 Aug, 2015 01:37 PM
Be my guest. SHARPY_UNIT_TESTS is just a quick product that I set up to run tests outside our usual products. There is nothing that can't be recreated there.
The history on that product is that I set it up Monday. I added a few plans, tracked items, and promotion codes. I also added the Native Gateway Simulator. I updated the secret key after posting all these requests yesterday.
Support Staff 13 Posted by Marc Guyer on 26 Aug, 2015 02:10 PM
Ok, thanks. I was able to replicate. It seems that we have an ACL bug specific to this particular action and scenario. It seems that it's deferring to the role with least permission and not assigning the appropriate role for your user. Dumping just the word "user" seems to also be related -- making this more difficult to track down. We'll get that fixed up as soon as we can. I would expect that by the end of the day. I'll keep you posted.
Support Staff 14 Posted by Marc Guyer on 27 Aug, 2015 03:44 PM
Just a quick update... We're having some trouble getting this replicated in a dev environment. We're working on it and I'll update you when we have a solution.
15 Posted by Ryan Johnston on 27 Aug, 2015 03:46 PM
Thanks for the update.
Support Staff 16 Posted by Marc Guyer on 27 Aug, 2015 05:03 PM
Ok, a hotfix has been developed, tested, and deployed. Your next run should be successful. Thanks for your patience and your help with this issue!
17 Posted by Ryan Johnston on 27 Aug, 2015 05:35 PM
The hotfix is working.
Thanks for all your help on this. You and your team have done it.
Marc Guyer closed this discussion on 27 Aug, 2015 08:16 PM.