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

Does mutation (via PUT or POST) work? #2

Open
gnuite opened this issue Apr 24, 2023 · 2 comments
Open

Does mutation (via PUT or POST) work? #2

gnuite opened this issue Apr 24, 2023 · 2 comments

Comments

@gnuite
Copy link

gnuite commented Apr 24, 2023

(I realize that this isn't yet a feature of the API as submitted, but...)

Has anyone been able to make changes to their system (e.g. changes to set points in /config) using either PUT or POST requests to the endpoints used in this API?

I tried PUT with read-modify-write JSON, but I got a 404 Not Found response.

Following the example of the requests sent by the myinfinitytouch.carrier.com web app, I tried sending POST requests with XML instead, but then I get a 401 Unauthorized response with the message, "signature doesn't match". I get this response even when sending to the /system_preference endpoint, which the web app does successfully use for mutations. I wonder which signature isn't matching - the OAUTH signature?

I'm still experimenting, but I'm wondering if anyone else has had success in making remote changes to their hardware.

@gnuite
Copy link
Author

gnuite commented Apr 25, 2023

Some progress: I have now successfully modified the /system_preference endpoint using POST with a single data=[xml] parameter. It turns out I just wasn't using aiohttp.FormData properly.

However, I'm still having trouble modifying /config. It turns out that if the XML has any space chars in it (elements with attributes, spaces in text, etc.), then I get the "signature doesn't match" error. (/system_preference doesn't have any spaces in it.)

Why are the spaces a problem? Well, from what I can tell, aiohttp.FormData insists on encoding spaces using the plus char (+), rather than %20; and my guess is that--somewhere in the stack--oauth1 (which expects it to be %20) is having trouble resolving the difference.

So, now I'm trying to figure out how to force the data param value to have %20 strings instead of + chars. Anyone know the easiest and/or most pythonic way?

@gnuite
Copy link
Author

gnuite commented Apr 25, 2023

I gave up on aiohttp.FormData. If I just manually pass data='data=' + urllib.parse.quote(xml), then it works fine. So programmatic control of set points is indeed possible. At least via POST and XML - I haven't been able to get it to work with JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant