Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

REST API to get Emails within a timeframe

Konstantin Schuckmann July 10, 2023

Hey dear Community, 

So currenbtly I am searching for a way to retrieve The Email content on each and every Ticket we receive. 
I know about rest/api/2/issues/search?jql= API but unfortunately it does not retrieve the HTML Emails of the Ticket. Is there any way to retrieve Emails alongside with ticket information via REST?    

2 answers

1 accepted

0 votes
Answer accepted
Sunny Ape
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2023

Hello @Konstantin Schuckmann 

Attached emails are stored inside the attachments field, but the Search for issues using JQL endpoint cannot return the contents of that field in any way, shape or form.

You will need to do the following:

1. Use the Search for issues endpoint with a JQL query to find the set of issues in the required date range.

2. From that set of issues, one-by-one for each issue, use the Get issue endpoint to get the contents of the attachments field to get the set of attachments and their IDs.

3. From that set of attachment IDs, one-by-one for each attachment, use the Get attachment content endpoint to get whatever is inside that email attachment.

 

Have fun.

Konstantin Schuckmann July 17, 2023

Thank you for the reply This one worked fine. 

I am just wondering if this approach will increase the computational power since the system is almost at the edge with all the current communication  

Sunny Ape
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2023

Glad it worked out.

As regards concerns about load effects... relax. You're on a CLOUD platform. There is practically no 'edge' that you can realistically reach :) The environment's computational power is dynamic scaled based on the overall load from millions of concurrent connections from tens of thousands of shared tenants and balanced across dozens of Amazon data centres around the planet.

That said, don't do silly things with the REST APIs or you will encounter the rate limits. Do your requests in batches, watch the response headers for the warning signs that you're flying too close to the sun, then back off your requests if required.

0 votes
Sayed Bares [ServiceRocket]
Community Champion
July 10, 2023

Welcome to the community @Konstantin Schuckmann !

Can you elaborate further on your use case?

What do you mean by the HTML email content? if you are searching for HTML tags then you can just use the following JQL:

text ~ "<html>"
Konstantin Schuckmann July 10, 2023

sure, 

I am searching for a way to retrieve the received Emails. 
Our current process is as follows
incoming email -> automatic Ticket creation via I dont know :-) -> all further mail communication is attached to this Ticket -> I search for created Tickets with mails and download these for further local process. 

When I use rest/api/2/search I get all coresponding info to any Ticket within inserted JQL, unfortunatelly no attached emails from the ticket. So I would like to see something similar like 

rest/api/2/serach?jql=created >(-1d) which outputs a JSON looking like so or similar like the one from rest/api/2/serach? but with the following additions 

{ticket_abc:{customfieldid_123: email in html format, customfieldid_124: email in txt format ...}

So each Ticket holds also all received emails in either txt format or html format

Is it clear now? 

 

Suggest an answer

Log in or Sign up to answer