Comments (16)
Found this in the dev blog: api changes
from hadotnet.
Actually I don't think the api changes are relevant. When I use curl to fetch the json, using the same uri and bearer, it works and I get a json string. When I deserialize that, using the classes in your project, it works.
When I extend your library to include the restsharp error message, it gives this:
Error: Found invalid data while decoding.
At a loss why it's saying that though. Any idea?
from hadotnet.
Ended up extending your library to use a curl fallback in case restsharp fails, which works fine for now.
from hadotnet.
I'm experiencing the same problem.
from hadotnet.
I'm experiencing this as described above. @SamKr can you share your fork that works?
from hadotnet.
Sure @PockyBum522, will do tomorrow.
from hadotnet.
Here you go @PockyBum522 : HADotNet fork.
Please read the readme for instructions. Let me know if it doesn't work for you.
from hadotnet.
Thank you very much! I'll have a chance to test today.
from hadotnet.
@SamKr What platform/OS are you running on? curl
isn't a Windows thing so I'm assuming you're on something else?
RestSharp may have issues on other platforms and that could be the cause. I can try bumping up RestSharp's dependency version to see if that resolves it.
from hadotnet.
I'm using Windows, curl is available for windows: https://curl.se/windows/
from hadotnet.
Well sure, but not out of the box and not (easily?) as a NuGet dependency... so CliWrap
fails if you didn't go out of your way to install curl
manually.
In any case, this looks like a bug with 0.118.x, I'll take a look and see if I can find out what changed.
Worst case, I can enhance that error message - response codes of 0 indicate a network issue of some kind, for which there's an error message that should be printed out in those cases.
from hadotnet.
Curl is a stand alone exe, so as long as I provide it along with the project's executable it's fine. And it's a backup method which is working fine for now.
I tried bumping restsharp and looking what's happening, but didn't get much result. Hopefully you'll do better :)
from hadotnet.
Why use Curl when you can use HttpClient? I don't understand. The REST API still works without any issues with HttpClient.
Ahh, nvm, probably because there is an issue in RestSharp.. Which is able to use a fallback.
from hadotnet.
The Curl solution doesn't work when performing Posts, any updates on a RestSharp solution?
from hadotnet.
Can confirm a basic HttpClient is working just fine:
var client = new HttpClient { BaseAddress = new Uri(""), Timeout = new TimeSpan(0, 0, 0, 0, -1) };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "***");
var request = new HttpRequestMessage(HttpMethod.Post, "/api/services/media_player/volume_up");
request.Content = new StringContent("{"entity_id":"media_player.living_room_speaker"}", Encoding.UTF8, "application/json");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
await client.SendAsync(request).ContinueWith(r => {
Console.WriteLine("Response: {0}", r.Result);
});
from hadotnet.
Version 1.4.0 has just been pushed out to NuGet that addresses this. Closing this issue.
from hadotnet.
Related Issues (14)
- C# Friendly Entity Classes
- ClientFactory.Initialize, how to check if connection is established ? HOT 1
- Issue with the Await and <EntityClient> HOT 3
- Deserializing array in attributes does not work HOT 1
- Unexpected response code 0 from Home Assistant API endpoint /api/states. HOT 2
- Exposing RestClient or adding helper methods (solves client certificate auth) HOT 3
- TLS 1.3 - Authentication failed because the remote party sent a TLS alert: 'ProtocolVersion'. HOT 1
- project test HOT 4
- Exception: Unexpected response code 404 from Home Assistant API endpoint /api/states/. HOT 1
- Error deserializing /API/SERVICES HOT 3
- Update Documentation and Add Code Examples
- Read /api/stream to receive server events HOT 3
- Donation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hadotnet.