Simple help in httpclient c#
I started to learn C# recently.
I tried to do on postman and it was successfull.
i wanna implement that feature with httpclient c#, but i face an issue.
Who can help me?
19 Replies
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, what you expect the result to be, what .NET version you are using and what platform/environment (if any) are relevant to your question. Upload code here https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code! (see $code for more information on how to paste your code)
Noone can help you if you don't ask your question. Include the code you currently have, and as much info on the request that worked in postman as possible.
and postman can generate the httpclient request for you
as a fully working piece of code
BlazeBin - jjlwdaoxyddi
A tool for sharing your source code with the world!
What is the issue you're facing?
"but I face an issue" does not explain anything
upload result: {"errors":[{"code":32,"message":"Could not authenticate you."}]}
The Share provider returned a Not Authorized message: '{"errors":[{"code":32,"message":"Could not authenticate you."}]}'
that is error
authorization error
401 status cod
Tbe Twitter API Twitter requires authorisation
And you're not doing that
Read their API docs to see what authentication method they use
Probably an API token or an auth bearer token
thanks for your support. So I have just resolved
but weird things are still existed in my code.
i used static value like that
What static value?
You can see on this
oauth signature
originally, i have to make it per reques
i made it but it's not working.
and that was my main issue
It should not be hardcoded in the first place
What do you mean? I am not familiar with it..
Could you please tell me detail?
possibly, with solution
yeah, i know, but i can't install any packages like .net frameworks because it's running on ninjatrader 8
You shouldn't hard code your API tokens
Store and retrive them in a file somewhere, or use env secrets
api token?
you mean oauth token or consumer key ?
Same thing