A Confusion about Raw query parameter - gmail-api

I am writing a simple migration tool in which I have to migrate gmail mailboxes to some other email provider. I am confused about raw string returned from gmail api.
In Google document, it says:
"raw": Returns the entire email message content in the raw field as a URL-safe base64 encoded string and the payload field is not used. This includes the identifiers, labels, metadata, MIME structure, and small body parts (typically less than 2KB).
So this means "raw" returns only small body parts less than 2kb and if the body parts are more than 2KB, there will be a problem. I have checked with some dummy emails containing email body(including inline attachments) more than 2KB, and it still works. It still returns the complete body without any problem. Sorry,if I missed something, please clear my confusion. If "raw" is working fine for all email body sizes , I will be using this approach in my project instead of "full" query parameter.
best regards,

messages.get(format=RAW) returns the entire email always. That document: https://developers.google.com/gmail/api/v1/reference/users/messages/get is incorrect and needs to be fixed.

Related

Logic app turn the binary to bad character

I created a logic app which gets the data from restapi. The content type of data is Application/protobuf(protobuf is a binary data made by google https://developers.google.com/protocol-buffers/docs/tutorials) I know that LA uses base64 encoding so it changes the data to base64 encoding. As the data to be deserialised via protoc complier so it needed binary format. So i store this data into a variable and trying to paas this further processing. But unfortunately the data stores in variable changes into boxes and ? So protoc compiler fails to deserialised the same.
I tried base64tobinary and http() as per suggestion mentioned section "other content type" on microsoft https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-content-type#applicationxml-and-applica...
But it did not work. Can anybody help on this?
I tried reproducing the issue and found that the rest API body which we are receiving will be transformed back to string when we use string() i.e.. string(triggerBody()) dynamic expression.
Later, I convert to binary by using the dynamic expression 'binary', i.e. 'binary(outputs('Compose')', which will return a 'application/octet-stream' result. When I tried to convert back to a string, everything worked great for me.
Here is the flow of my logic app
and here is the output
I have changed the way of using. Instead of streaming, I am storing the data into file and processing further.

JMSTimestamp Vs Other Date storing headers on a JMS message

I'm using AMQs REST API to send a message to a Queue with a header set in the queryString.
I'm setting a date header myDateHeader with the millisecond value of a UNIX timestamp.
&myDateHeader=1583781133771
The JMSTimestamp header is being set automatically for me, and also seems to be set as a long....
I then consume this message with camel, albeit in Talend, and can 'parse' the JMSTimestamp to a formatted date.
However when I try to do the same with myDateHeader I get null back.
Both JMSTimestamp and myDateHeader show values if I 'parse' to String and Long so something is (not) happening as part of the date parsing.
Talend code shows
row5.Event_Timestamp = org.apache.camel.builder.SimpleBuilder
.simple("${in.header.myDateHeader}")
.evaluate(routerExchange, java.util.Date.class);
showing the correct resultType as per the SimpleBuilder class. The code is the same as that generated for parsing the JMSTimestamp.
Also when I try
simple("${date:in.header.myDateHeader:yyyyMMdd}")
I get
java.lang.IllegalArgumentException: Cannot find java.util.Date object at command: in.header.myDateHeader
I'm guessing:
1) that when the message is created, the header needs to be set with a correct type of Date to be able to do this date parsing as part of consumption?
2) And that the REST API sets all headers with type String and I can't change this through my REST call?
Excuse my guesses but am hoping if someone can confirm the above, and therefore that I can't treat myDateHeader the same as the JMSTimestamp header when consuming these messages?
thanks
Your second assumption is correct. Custom headers are parsed with type String. In Talend, as well as in Apache Camel, which is a Talend ESB's underlying integration framework, the predefined JMS headers including JMSTimestamp are converted to Java types according to the "Message format when receiving" reference table.

Forward message using the Gmail API without using JavaMail

Is there a way to use the Gmail API based Message object to forward a message without using the JavaMail library (Javax)?
Thanks.
Looking for a way to bounce the Message object to another recipient WITHOUT using any JAVAMAIL classes (MimeMessage for instance)
So far no luck cause I'm pretty sure that the message's Raw will have to be re-encoded somehow.
Will love some help.
EDIT:
Found one solution which is equivalent to bouncing an message to another recipient. Thanks to Eric for the pointing me in the right direction. use the Gmail API get method for the specific email with "raw" format. decode the raw string from the parsed message->replace "To:" with new recipient address and re-encode the raw (base62url). Create a new message with newly encoded raw and send
Depends on what you mean by "Forward" I imagine. If you mean it in the "bounce message" of old mailers of yore (resend the exact same content to a new recipient without changing body or headers) then yeah should be trivial.
If, instead, you mean what more current mailers do when you forward it (set new From, To, Subject headers, include original To+Cc+From headers somewhere in the body below something like "Forwarded message" and your own user-added content) then you probably need to deal with something like javax.mail for those changes. If you're sure the emails are simple (e.g. just a text/plain part) you could attempt it without javax.mail and use the parsed Message object (format=FULL) to create a new email. But javax.mail is probably best.

Gmail API Users.Messages.get return some messages without any label

Trying to get messages from Gmail using RESTFul API using get operation and some messages are returned empty labels (other parts of the payload are ok).
What is the reason to get empty labels ?
Thanks
Messages without labels are archived messages.
This seems like expected behavior. If they don't have any labels (e.g. not even INBOX) then they are simply in All Mail (e.g. they have been archived and are in the mailbox, etc).

Using PreAnalyzedField in Solr 4

I am trying to index fields using Solr, in which I already have a TokenStream. I dont want Solr to have any analysis - Its already made. As I understood, I could get this exact functionality using Solr's PreAnalyzedField.
The problem is that I cannot find any good resource to help me understand the flow:
I needto define the field in the schema.xml file as PreAnalyzedField, and the tokenstream should be parsed using the parse method of the parser implementation - but how to I actually feed the field with my tokeStream? how \ when exactly is it sent to the toFormattedString method???
I think PreAnalyzedField is a bleeding edge of Solr as of 4.0/4.1. The main documentation is on the Wiki and basically explains the two parser types. The default is JSON, I am not sure how to get the other type to work.
Once you have that type defined, you just supply fully-tokenized content in the JSON format as described as that field's value. When that hits the parser, it will convert it to the Token stream. The same way a number gets parsed from a string representation into a real numeric representation. Try feeding an unparsable value and you will see the full call stack in the exception stacktrace.
The problem is how to query it. My own discussion on the mailing list did not get very far.

Resources