How do you query sent items using gmail api? - java

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).

Related

How to use Binance API, simple GET price by ticker

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'."}

How to pass an url by a rest api URL string

I have a table a with columns like pageId and page_name where values are inserted line [1,https://google.com] and so on.
Now i created an api that takes the URL and returns the pageid, so now the scenario is like:
localhost:8080/api/v1/page/https://google.com
whenever i am trying to pass it via Postman is is showing Could not send response can anyone help me to fix this problem?
The problem is that you have reserved chars in your query param.
Consider encoding your text.
So:
http://www.google.com
will become:
http%3A%2F%2Fwww.google.com
localhost:8080/api/v1/page/https://google.com
According url format documentation (see for example this article )- impossible use reserved chars (: and /) as parameters. I reccoment use something like
localhost:8080/api/v1/page/google.com
And add "https://" in service
or use
localhost:8080/api/v1/page/https~~google.com
And replaced "~~" to "://".

GMail API aliases.getSendAs().get(0).getDisplayName returns empty (only for 0, not for the next ones)

I'm using Java GMail API and everything is working good for sending e-mails, collecting data from my profile, etc.
The only problem is that, while I can get the Signature for my 0-th element of the list of SendAs aliases, I can't get the Display Name: it returns an empty String. Both work for the other aliases (get(1) and subsequent numbers). It seems that the problem is on 0, tried on different authenticated users with Name set and it remains the same.
ListSendAsResponse aliases = service.users().settings().sendAs().list("me").execute();
SendAs mimmo = aliases.getSendAs().get(0);
actualsign = mimmo.getSignature();
sendername = mimmo.getDisplayName();
In Gmail API, there are two different ways to retrieve alias(es):
getSendAs() and SendAs.Get(java.lang.String userId,java.lang.String sendAsEmail)
The first one returns you a list of all alias, the second returns you one alias ressource - the one with the specified userId and sendAsEmail parameters.
If what you want to do it to retrieve the first element of the getSendAs() response, you should do it with getSendAs()[0] and not with the Java method get.
Sample:
SendAs mimmo = aliases.getSendAs()[0];
System.out.println(mimmo.getDisplayName());
It is always useful to test with the Try this API what response a method returns. Thereby, the userId can be set to me.

How to add com.google.appengine.api.datastore.PhoneNumber Param from Api explorer to a Form

I have a form which takes Mobile number as com.google.appengine.api.datastore.PhoneNumber type param named as mobileNumber. It somewhat looks like this in API Explorer
This mobileNumber Field appears as a field enclosing number param which is the use to store number internally by PhoneNumber class. When I enter number here in the given format. It gives IllegalArgumentException (BadRequest 400).
Can anyone explain how to use PhoneNumber datatype in a form while using API Explorer for testing the API ?

How LDAP search filter string accepts space?

I feel a bit nervous because this is my first question here at Stack Overflow. Please let me know if I am not doing it in a good manner.
In LDAP, I think the following search filter string works.
( & (uid=tt4cs) (objectClass=inetOrgPerson) )
It means searching for entries, one of whose uid is tt4cs and one of whose objectClass is inetOrgPerson.
Please note that there are spaces between every parenthesis and ampersand, which will just be ignored. But, as far as I read RFC4515, I can find no implication that allows any space that way. Could anybody kindly tell me whether it is allowed by any other standards or it is just so by convention?
Update on Jan 13, 2014
I have tested it in three ways. (LDAP server in my environment is OpenLDAP 2.4.38)
(1) Do ldapsearch on command line. The above search filter works and gets a result.
(2) Search by using UnboundID LDAP SDK for Java. This API does not send the search request to the server, but throws an exception that says "Unexpected closing parenthesis found at position 15 of the filter string."
String filter = "( & (uid=tt4cs) (objectClass=inetOrgPerson) )";
SearchResult searchResult
= connection.search("dc=localdomain", SearchScope.SUB, filter);
(3) Search by using Apache Directory LDAP API. This API does not send the search request to the server, but throws an exception that says "The filter ( & (uid=tt4cs) (objectClass=inetOrgPerson) ) is invalid."
String filter = "( & (uid=tt4cs) (objectClass=inetOrgPerson) )";
EntryCursor cursor
= connection.search("dc=localdomain", filter, SearchScope.SUBTREE);
Now I have a feeling that acceptance of the extra spaces may probably be an implementation-dependent behavior, and that it is better to avoid it.

Categories