I would like to get only one pair from the response. And I can't really understand how I should pass my parameter.
Instructions say:
Symbol price ticker
GET /api/v3/ticker/price
Latest price for a symbol or symbols.
Weight: 1 for a single symbol; 2 when the symbol parameter is omitted
Parameters:
Name Type Mandatory Description
symbol STRING NO -
If the symbol is not sent, prices for all symbols will be returned in an array."
I'm able to get all symbols in the response body, but can't get a single one.
I have already tried (in Postman) these endpoints:
https://api.binance.com/api/v3/ticker/price/btcusdt
https://api.binance.com/api/v3/ticker/price/symbol=btcusdt
https://api.binance.com/api/v3/ticker/price/?symbol=btcusdt
Here is the link to entire API:
https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#24hr-ticker-price-change-statistics
So, which endpoint is correct? postman result
https://api.binance.com/api/v3/ticker/price/?symbol=btcusdt
You must use Query without /
and Binance's /api/v3/ticker/price endpoint need symbol query as Upper case.
so you must request as below
https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT
You can you this API link to get all pairs only current price and symbols:
https://www.binance.com/api/v3/ticker/price
This for specific symbol and price:
https://www.binance.com/api/v3/ticker/price?symbol=BNBBTC
This for all pairs with full info:
https://api.binance.com/api/v3/exchangeInfo
This for 1 pair full info:
https://api.binance.com/api/v3/exchangeInfo?symbol=BNBBTC
Here is Binance API Detail pages:
https://binance-docs.github.io/apidocs/spot/en
https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md
Is there a chance to send more queries at once like for example
BTCUSDT and ETHUSDT ?
When I am trying various combinations I get a reply of:
{"code":-1104,"msg":"Not all sent parameters were read; read '1' parameter(s) but was sent '2'."}
Related
I am using
compile group: 'com.graphql-java',
name: 'graphql-java-tools',
version: '5.2.4'
type Query {
sampleQuery(roll : Int!) : SampleResponse
}
When I am trying to access this as given below in java
{sampleQuery(roll : ?2){samples{roll,name}}}
It gives 200 success response instead of 400 error response (as we are trying to pass invalid value in the input).
Here, the integer input accepts the values like ?2 or .2 or '2 or *2 or /2 etc...
Why does it accept it?
What can I do to validate this input and throw error saying invalid input param?
Is this an issue from graphQl implementation itself?
In the console logs I do get
line 2:72 token recognition error at: '?'
but I also get correct response for it. Ideally, this should not return valid response as the input itself is invalid.
The main question is why don't graphQL validates integer input; rather it parses the input(discards the characters along with the digits)? It should strictly accept only the integer values and nothing else.
So as per the graphql grammer, it allows(parses) the integer value appended with some characters(tokens) (like ?,~`/*...etc) But it does not allow the punctuators like #,&,$,!,{,],[,|, etc.
Therefore, 200 success response is received and error is not thrown in this case.
Reference:
https://spec.graphql.org/draft/
I have an API which gets the company name as the query parameter and fetches the company details in JSON format.
The issue is, Name contains the Trade Mark symbol. So the API is failing and throwing an error
Example: http://localhost:8080/company/companyname=ABC TM(Trademark Symbol) Ltd
Error is:
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
Checked different sites but didn't find anything related to passing TM symbol in URL.
Example: http://localhost:8080/company/companyname=ABC TM(Trademark Symbol) Ltd
I want a solution to accept the trademark symbol in the URL that would work and retrieve the results.
I am trying to use Rest Assured in the Serenity framework to validate an endpoint response. I send an xml body to the endpoint and expect a JSON response back like so:
{"Entry ID" : "654123"}
I want to send the XML and verify in the JSON response that the value of the key "Entry ID" is not empty or null. The problem is, the key has a space in it, and I believe it is causing an error. Here is what I have so far:
SerenityRest.given().contentType(ContentType.XML)
.body(xmlBody)
.when().accept(ContentType.JSON).post(endpoint)
.then().body("Entry ID", not(isEmptyOrNullString()))
.and().statusCode(200);
This produces the error:
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: unable to resolve class Entry
# line 1, column 33.
Entry ID
^
1 error
I have tried wrapping the "Entry ID" term in different ways to no avail:
.body("'Entry ID'", not(isEmptyOrNullString()))
.body("''Entry ID''", not(isEmptyOrNullString()))
.body("\"Entry ID\"", not(isEmptyOrNullString()))
.body("['Entry ID']", not(isEmptyOrNullString()))
.body("$.['Entry ID']", not(isEmptyOrNullString()))
Is it possible to get the value of a key that contains a space in Rest Assured?
You just need to escape the key with single quotes:
then().body("'Entry ID'", not(isEmptyOrNullString()))
Here's an example (tested in version 3.0.6):
// Given
String json = "{\"Entry ID\" : \"654123\"}";
// When
JsonPath jsonPath = JsonPath.from(json);
// Then
assertThat(jsonPath.getString("'Entry ID'"), not(isEmptyOrNullString()));
When I use label:sent as a search query in the gmail UI it takes me to sent items but when I use a labelId of sent from the gmail API for messages (https://developers.google.com/gmail/api/v1/reference/users/messages/list) I get an error "Invalid label: sent" - just wondering how do I query for sent items from the API? Also is there a reference / examples for the type of input you can use for the "q" input parameter for the gmail API?
Thanks
If you're doing a list with "?labelId=" then use "SENT" (in upper case) as per:
https://developers.google.com/gmail/api/guides/labels
(those should probably be case insensitive but they are not.)
For the "?q=" parameter to the list methods it says on the URL you give:
Supports the same query format as the Gmail search box. For example, "from:someuser#example.com rfc822msgid: is:unread".
For more examples, I just tried searching for "gmail search queries" and got:
https://support.google.com/mail/answer/7190?hl=en
which gives lots of useful keywords, they should all work with the "q=" parameter (you may need to URL escape them, depending on language/client libraries).
I have written a java servlet to deal with http get request.I know ,the common format of get request is like this:http://IP_ADDRESS:8080/test?name="jack"&value="shit.
But now ,I have a list of values to transfer,such as an user id list[1,2,3,4].So ,my question is ,how should I write my http get request to express this?And in java servets doGet(),can I use request.getParameterValues to get such an array?
if you are using GET method your url should be looking like that :
http://IP_ADDRESS:8080/test?list=1&list=2&list=3
for retrieving it:
String[] arrlist=request.getParameterValues('list');
your array will be filled with separated values:
//["1","2","3"]
UPDATE : if to write it list[] or list?
when you retrieving your list parameters it wouldn't be parsed as array but as a series of String which will be grouped later on into an array.
Which means even if you write it list[]=1&list[]=2&list[]=3, list[=1&list[=2&list[=3, list*=1&list*=2&list*=3 or list=1&list=2&list=3 it would always be giving you the same answer whether you retrieve it as
request.getParameterValues('list[]') //["1","2","3"]
request.getParameterValues('list[') //["1","2","3"]
request.getParameterValues('list*') //["1","2","3"]
request.getParameterValues('list') //["1","2","3"]
While ,the http request format should be like this:localhost:8080/test?list[]=1&list[]=2&list[]=3
Maybe too simple, but what about repeat parameters name?
http://IP_ADDRESS:8080/test?userId=1&userId=2&userId=3