Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Bad Request #20

Closed
davesenior9 opened this issue Mar 30, 2023 · 10 comments
Closed

400 Bad Request #20

davesenior9 opened this issue Mar 30, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@davesenior9
Copy link

davesenior9 commented Mar 30, 2023

400 Bad Request
Traceback (most recent call last):
  File "request_reports.py", line 189, in <module>
    res = json.loads(response.read())['results']
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Have you encountered this before? I have automated the polling of this script, and had it running for a few days. It abruptly stopped and generated this error. Restarting the script made no change. If i go back to vanilla OHS and use the GUI, it updates fine.

Thanks!

Additional Info drawn from response headers.

[('content-length', '0'), ('via', 'xrail:st53p00ic-qujn14040502.me.com:8301:22R920:grp60,631194250daa17e24277dea86cf30319:0299c4cf8819616e8ba5700c89695c8d:jptyo12'), ('access-control-expose-headers', 'X-Apple-Request-UUID,Via'), ('strict-transport-security', 'max-age=31536000; includeSubDomains;'), ('x-responding-instance', 'acsnservice:2:prod-p00-acsnservice--partial-5b7df67f59-sx8n8:80:2388B9802:6a2bc5323182'), ('server', 'AppleHttpServer/3faf4ee9434b'), ('x-apple-jingle-correlation-key', '<removed>'), ('connection', 'keep-alive'), ('apple-seq', '0'), ('x-apple-user-partition', '0'), ('date', 'Thu, 30 Mar 2023 01:23:32 GMT'), ('x-apple-request-uuid', '<removed>'), ('apple-tk', 'false'), ('apple-originating-system', 'UnknownOriginatingSystem'), ('x-apple-edge-response-time', '168')]
@EbonyHuang
Copy link

We see the same issue here. If you print out response.status and response.reason, it shows that 400 Bad Request. This seems mean the incorrect header/data is posted to server.
But why it happened?? Not sure what's wrong???

@biemster
Copy link
Owner

Odd stuff! What OS are you on @davesenior9 and @EbonyHuang ? I'll have to spin up my macOS dockers to see if I can reproduce. Do both the request_reports.py and FindMy_client.py fail for you? (it might be related to the startDate and endDate fields, I've noticed some server-side changes in that area).

@EbonyHuang
Copy link

For both BigSur and Monterey OS, the request_report.py has the same failure. It all works couple days ago. Thank you.

@EbonyHuang
Copy link

Looks like it is the https body(search) contain the single quote ' in the "ids" list, when we replace that single quote to be double ". It seems work again.
add this line before do the https post.
data = data.replace("'",'"')

@davesenior9
Copy link
Author

awesome work. thats fixed it for me. I would be interested to know what caused this. Some sort of change on the Apple gateway?

@biemster
Copy link
Owner

Well done @EbonyHuang ! The ids list was a bit hacky indeed, I guess Apple updated a json parser somewhere, not allowing single quotes anymore. I'll put in a fix when I find the time.

@biemster biemster pinned this issue Mar 31, 2023
@biemster biemster added the bug Something isn't working label Apr 26, 2023
@biemster
Copy link
Owner

Reopening because this definitely needs the fix by @EbonyHuang

@biemster biemster reopened this Apr 26, 2023
@mrx23dot
Copy link

mrx23dot commented Jun 5, 2023

got the same issue,
response was 0 len
i think it fails in

    def do_OPTIONS(self):
        self.send_response(200, "ok")

before
def do_POST(self):
is called

had to replace six with flask.

@biemster
Copy link
Owner

biemster commented Jun 5, 2023

@mrx23dot the fix is already given in #20 (comment), I just need to push that to the repo. In the meantime you can just add that in your clone.

@biemster
Copy link
Owner

biemster commented Nov 1, 2023

This should be fixed now in both the catalina and monterey branches. Also main of course but that is undergoing major overhaul at the moment, to abolish the requirement of a mac altogether.

@biemster biemster closed this as completed Nov 1, 2023
@biemster biemster unpinned this issue Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants