Wondering why api call to swap token to token (sUSD to ETH or WETH) is failing
curl -X GET "https://api.1inch.exchange/v3.0/1/swap?fromTokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f&toTokenAddress=0x5e74c9036fb86bd7ecdcb084a0673efc32ea31cb&amount=10&fromAddress=0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5&slippage=1" -H "accept: application/json"
{
"statusCode": 500,
"message": "cannot find path for 0x5e74c9036fb86bd7ecdcb084a0673efc32ea31cb",
"error": "Internal Server Error"
}
The token is listed in the /tokens api call..
API Playground:
https://api.1inch.exchange/swagger/ethereum/#/Swap/SwapFactoryController_getQuote
Related
When making a request to the MapBox API to create a new dataset we keep getting a response 404 {
"name": "foo",
"description": "bar"
}.
We are sending the code:
curl -X POST “https://api.mapbox.com/datasets/v1/username?access_token=TOKEN” \
-d #mapboxtest.json \
--header “Content-Type:application/json
Problem Solved!!!
It's just a wierd message. My token key is not allowed to change datasets, that was the problem. It was the default public key!
I am looking for a way to generate token using login/password on reportportal.
Pretty sure, there should be a way using a API call. I am just not able to find it.
So given, (project name, user, password), I should get a token that I can use for making other API calls.
Thanks.
Get API token
Before getting API token, you have to generate it.
If it's already generated (you have logged in with this user), this endpoint will return you existing API token:
GET /sso/me/apitoken
Example:
curl -X GET --header 'Accept: application/json' --header 'Authorization: bearer 4f73871b-e477-4f49-b1bd-805b24201fe0' 'http://web.demo.reportportal.io/uat/sso/me/apitoken'
Response:
{
"access_token": "b1debc0a-d47d-492f-aa7c-3e2e0fb96332",
"token_type": "bearer",
"scope": "api"
}
Pay attention, that bearer in 1st (curl) request has scope UI and bearer in response has scope API.
UI token expires according to server config and TimeToLive for user session.
API token has endless TTL
** If GET requests returns you error, then you need to generate token.
Generate API token
POST sso/me/apitoken
Example:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: bearer 4f73871b-e477-4f49-b1bd-805b24201fe0' 'http://web.demo.reportportal.io/uat/sso/me/apitoken?authenticated=true'
Response:
{
"access_token": "4e76e31e-0250-4e5e-ba66-90105dd014bb",
"token_type": "bearer",
"scope": "api"
}
(!) Tokens are public. Used from public account at demo instance http://web.demo.reportportal.io
Make a post to:
/uat/sso/oauth/token?grant_type=password&password=***password***&username=***username***
Set basic authentication with credentials (username: ui and password: uiman) to get the accesstoken for scope UI, use this token to fetch apitoken.
I am testing out push notifications for iOS Development and am currently using Pusher. When I run this command in terminal
curl -H "Content-Type:application/json" -H "Authorization: Bearer 7FF3763C208E26F2198CE44624E9486B1EC8B02A489DCF2F476FD511763887AE" -X POST 'https://d3ca6e4b-3222-49c9-8028-f9c2d28b3ad7.pushnotifications.pusher.com/publish_api/v1/instances/d3ca6e4b-3222-49c9-8028-f9c2d28b3ad7/publishes' -d#publish-body.json
It gives me this warning
Warning: Couldn't read data from file "publish-body.json", this makes an empty
Warning: POST.
{"error":"Bad Request","description":"Failed to read body as a JSON
object"}
Here is my JSON file
{
"interests": [
"Reminder"
],
"apns": {
"aps": {
"alert": {
"title": "Hello",
"body": "Hello, world!"
}
}
}
}
I tried going to the Pusher API and all it told me is that the error is due to a bad request. Any ideas on how to fix this? This app is a gift for my girlfriend and I would love to have this working!
I have a sample code here. It is json
{
"document":{
"type":"PLAIN_TEXT",
"content":"Joanne Rowling, who writes under the pen names J. K. Rowling and Robert Galbraith, is a British novelist and screenwriter who wrote the Harry Pott$
},
"encodingType":"UTF8"
}
I found a tutorial on google's documentation on Natural Language processing on reading from Google Cloud Storage.
curl -X POST \ -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \ --data "{
'document':{
'type':'PLAIN_TEXT',
'gcsContentUri':'gs://reubucket/textData'
}
}" "https://language.googleapis.com/v1/documents:analyzeEntitySentiment"
And the error that I got is
ERROR: (gcloud.auth) Invalid choice: '*************-_m6csS1Wzlj1pyC_J7vzC0'.
Usage: gcloud auth [optional flags] <group | command>
group may be application-default
command may be activate-service-account | configure-docker | list |
login | revoke
How do I call the command with my API key.
I need a way to change the "content" to entries into my CSV file.
Thank you.
Here is an example of the error that I am receiving please help:
mufaroshumba#reucybertextmining:~/myFolder$ gcloud auth activate-service-account --key-file="/home/mufaroshumba/myFolder/reucybertextmining-74fa66372251.json"
Activated service account credentials for: [starting-*******[CENSORED]#reucybertextmining.iam.gserviceaccount.com]
mufaroshumba#reucybertextmining:~/myFolder$ curl "https://language.googleapis.com/v1/documents:analyzeSentiment?key=${API_KEY}" \ -s -X POST -H "Content-Type: app
lication/json" --data-binary #request.json
{
"error": {
"code": 401,
"message": "Permission to access the GCS address is denied.",
"status": "UNAUTHENTICATED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document.gcs_content_uri",
"description": "Permission to access the GCS address is denied."
}
]
}
]
}
}
curl: (6) Could not resolve host: -s
mufaroshumba#reucybertextmining:~/myFolder$
I then used this website trying to get
It looks like your auth is not setup correctly. If you just run this command:
gcloud auth application-default print-access-token
it should be giving you a token, but it seems like it's not. Please follow the steps here to make sure that this command is working first:
https://cloud.google.com/natural-language/docs/quickstart#quickstart-analyze-entities-cli
Then, as long as you have permission to access the gcs bucket, you should be able to get content out of it. Note that the API is expecting to see the actual content in the gcs file, and not a CSV.
I have a URL https://mylink/apply?data= for a server which accepts the data variable as valid JSON of following properties:-
name: String with your name (required)
email: String with your email address (required)
urls: Array of strings with links
comment: String with any comment/request you might have (optional)
My JSON file "data.json" is the following:
{
"data":
{
"name": "Rogers Bell",
"email": "xxxx#gmail.com",
"urls":["https://stackoverflow.com/users/3067241/imran", "https://github.com/i4ali"],
"comment":"none"
}
}
When I use the following CURL command to send a POST request, I get error code 400 Bad Request with a message from the server Error: no data passed. indicating something wrong with my JSON format or command. Not sure what I am doing wrong here
curl -v -i -X POST -d #data.json https://mylink/apply?data= -H "Accept: application/json" -H "Content-Type: application/json" -k
I am using Windows 7 if that matters
The API is pretty weird. But if you have to read JSON file and POST its content to server as URL parameter, you can cat the file, encode it and send it in curl. Here is an example:
curl -G -X POST https://requestb.in/1n88lah1 --data-urlencode data="$(cat input.json)"
The input.json would look like:
{
"name": "Rogers Bell",
"email": "xxxx#gmail.com",
"urls":["https://stackoverflow.com/users/3067241/imran", "https://github.com/i4ali"],
"comment":"none"
}
Using Postman I was able to send this POST request with the following complete URL. Got a 200 OK response
https://mylink/apply?data={
"name": "Rogers Bell",
"email": "xxxx#gmail.com",
"urls":["https://stackoverflow.com/users/3067241/imran", "https://github.com/i4ali"],
"comment":"none"
}