Comments (7)
Hi there @lawyerz8! In Windows, curl
is actually an alias for Invoke-WebRequest
, which has its own syntax for passing headers. You'll want to try something like this:
$creds = 'up:yeah:...'
Invoke-WebRequest 'https://api.up.com.au/api/v1/util/ping' -Headers @{ 'Authorization' = "Bearer $creds" }
You can even try using Invoke-RestMethod
, which will give you a nicer output:
$creds = 'up:yeah:...'
Invoke-RestMethod 'https://api.up.com.au/api/v1/util/ping' -Headers @{ 'Authorization' = "Bearer $creds" }
from api.
also @lawyerz8 - your third screenshot was so close. If you want to go down the curl
path, you can:
$headers = @{ "Authorization" = "Bearer up:yeah:...." }
curl "https://api.up.com.au/api/v1/util/ping" -H $headers
But, I agree - Invoke-RestMethod
does give a much nicer output 😄
from api.
@lawyerz8 - i might have led you astray there. It seems that in powershell, you can use either '
or "
- it doesn't matter. so, all of these work:
curl "https://api.up.com.au/api/v1/util/ping" -H @{ 'Authorization' = 'Bearer up:yeah:....' }
curl 'https://api.up.com.au/api/v1/util/ping' -H @{ "Authorization" = "Bearer up:yeah:...." }
curl 'https://api.up.com.au/api/v1/util/ping' -H @{ 'Authorization' = "Bearer up:yeah:...." }
which is a bit confusing - it's generally recommended to pick one kind and stick with it.
from api.
@lawyerz8 welcome to programming! So good to hear you're rolling up your sleeves and keen to have a go with this. I don't have a good answer for you right now (I'll try and get one... I'm less familiar with Windows). But what I can say is that you definitely don't need to (and should not) prefix a $
sign to the token.
Imagine your token was: up:yeah:xyz123abc
(but much longer in reality), then the correct header to send would be:
Authorization: Bearer up:yeah:xyz123abc
from api.
Try taking out that backslash before the -H
too. The backslash is just an escaping character to handle a single curl command spanning multiple lines, but given you're supplying it all on one line, it shouldn't be needed (I imagine it will not be causing any problems, as it likely just "skips" the following space character, but remove it nevertheless).
from api.
Thank you all! You guys are legends. Both queries above work! I'll work my way down the other examples :)
Was very confused about the " as well. Glad to note it is actually part of the query.
Interesting how Invoke-Rest method uses ' but curl/Invoke-WebRequest uses "
from api.
Oh man I just discovered Postman https://www.postman.com/downloads/ isn't this so much better than CLI haha...
Now i'll try to write it to a database..?
from api.
Related Issues (20)
- 2up tags aren't working as expected HOT 1
- Demo tokens
- Grammatical error in the Error Response documentation. HOT 1
- Receiving 'Invalid Parameter' for a valid rfc-3339 date using filter[since] HOT 3
- Expose Spendable Balance HOT 4
- Feature Request: Expose Upcoming List HOT 1
- Feature Request: Be able to match a contribution in a two up account HOT 1
- Feature Request: Include savers goal amount in Accounts API response HOT 2
- List transactions by account endpoint returns html when using invalid accountId HOT 1
- No Account Info for deleted Transactions HOT 6
- Incorrect RFC Validation on filter[until] and filter[since] HOT 1
- Identifiable Transaction Owners HOT 3
- Get more than 100 transactions and Filter on Tags HOT 2
- Transfer verses Roundup inconsistency HOT 4
- Transfer money between savers HOT 2
- Transactions endpoint to return notes field HOT 6
- Expose Payments and Savers Information HOT 2
- Is the Up Bank API going to be expanded? HOT 8
- Generate token in app HOT 3
- API Bugs 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 api.