Get Notification Data
When sending notifications with ReturnMode as RESUME, the response will be a RequestID that you can use to get the notification data.
This service will return information about the number of notifications sent, processed and processing.
JSON Body
{ "hash": "COMPANY_HASH", "sentId": 00}
- hash: Hash of the company where the template is registered
- sentId: The generated ID when sending notifications in ReturnMode = RESUME
Response
- The response is a json with the following structure:
{ "success": true, "message": "OK", "content": { "RequestId": 1, "RequestDate": "2023-06-05T16:00:00", "RequestStatus": "PROCESSED", "TotalNumberReceived": 4, "TotalNumberValid": 4, "TotalNumberSuccess": 4, "TotalNumberError": 0, "TotalNumberWaiting": 0, "TotalNumberCanceled": 0, "RequestResult": [ { "RequestSeq": 1, "RequestPhoneNumber": "111111111", "RequestStatus": "sent", "RequestMessage": "OK", "RequestSentDatetime": "2024-08-05T16:00:00", "RequestDeliveryDatetime": "2024-08-05T16:00:00", "RequestReadDatetime": "2024-08-05T16:00:00", "RequestHasButton": true, "RequestUserAnswered": true, "RequestUserAnswer": "Sim", "SentKeys": [ { "Description": "NOME", "Value": "Giuliano" } ], "SentParms": [ { "Cod": "CPF", "Value": "11111111111" }, { "Cod": "RG", "Value": "11111111-1" } ] }, { "RequestSeq": 1, "RequestPhoneNumber": "222222222", "RequestStatus": "sent", "RequestMessage": "OK", "RequestSentDatetime": "2024-08-05T16:00:00", "RequestDeliveryDatetime": "2024-08-05T16:00:00", "RequestReadDatetime": "2024-08-05T16:00:00", "RequestHasButton": true, "RequestUserAnswered": true, "RequestUserAnswer": "Sim", "SentKeys": [ { "Description": "NOME", "Value": "Giuliano" } ], "SentParms": [ { "Cod": "CPF", "Value": "11111111111" }, { "Cod": "RG", "Value": "11111111-1" } ] }, { "RequestSeq": 2, "RequestPhoneNumber": "333333333", "RequestStatus": "sent", "RequestMessage": "OK", "RequestSentDatetime": "2024-08-05T16:00:00", "RequestDeliveryDatetime": "2024-08-05T16:00:00", "RequestReadDatetime": "2024-08-05T16:00:00", "RequestHasButton": true, "RequestUserAnswered": true, "RequestUserAnswer": "Sim", "SentKeys": [ { "Description": "NOME", "Value": "Giuliano" } ], "SentParms": [ { "Cod": "CPF", "Value": "11111111111" }, { "Cod": "RG", "Value": "11111111-1" } ] }, { "RequestSeq": 2, "RequestPhoneNumber": "444444444", "RequestStatus": "sent", "RequestMessage": "OK", "RequestSentDatetime": "2024-08-05T16:00:00", "RequestDeliveryDatetime": "2024-08-05T16:00:00", "RequestReadDatetime": "2024-08-05T16:00:00", "RequestHasButton": true, "RequestUserAnswered": true, "RequestUserAnswer": "Sim", "SentKeys": [ { "Description": "NOME", "Value": "Giuliano" } ], "SentParms": [ { "Cod": "CPF", "Value": "11111111111" }, { "Cod": "RG", "Value": "11111111-1" } ] } ] }}
- Possible values for base RequestStatus:
- CANCELED
- QUEUED
- PROCESSED
- PROCESSING
- Possible values for RequestResult Status:
- canceled
- waiting
- sent
- delivered
- failed
Examples
var httpClient = new HttpClient { BaseAddress = new Uri("YOUR_ANNA_URL") };
var result = await httpClient.PostAsJsonAsync("REST/Credentials/GetToken", new { hash = "COMPANY_HASH", user = "USER", pass = "PASSWORD" });
var tokenResponse = await result.Content.ReadFromJsonAsync<GetTokenResponse>();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResponse?.Data.Token);
var getDataResult = await httpClient.PostAsJsonAsync("REST/Notifications/GetData", new { hash = "COMPANY_HASH", sentId = 00 });
var getDataContent = await getDataResult.Content.ReadAsStringAsync();
return getDataContent;
public class GetTokenResponse { [JsonPropertyName("success")] public bool Success { get; set; }
[JsonPropertyName("message")] public string Message { get; set; } = string.Empty;
[JsonPropertyName("data")] public TokenData Data { get; set; } = new(); }
public class TokenData { [JsonPropertyName("Token")] public string Token { get; set; } = string.Empty;
[JsonPropertyName("ExpiresIn")] public string ExpiresIn { get; set; } = string.Empty; }
public class Main { public static void main(String[] args) throws IOException, InterruptedException { var httpClient = HttpClient.newHttpClient(); Gson gson = new Gson();
String environmentUri = "YOUR_ANNA_URL";
var credentials = new HashMap<String,String>(); credentials.put("hash", "COMPANY_HASH"); credentials.put("user", "USER"); credentials.put("pass", "PASSWORD");
var credentialsJson = gson.toJson(credentials);
var httpRequest = HttpRequest.newBuilder() .uri(URI.create(environmentUri + "REST/Credentials/GetToken")) .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(credentialsJson)) .build();
var credentialsResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
var tokenObj = gson.fromJson(credentialsResponse.body(), GetTokenResponse.class);
var getDataRequestBody = new HashMap<String, Object>(); getDataRequestBody.put("hash", "COMPANYHASH"); getDataRequestBody.put("sentId", 00);
var getDataRequestBodyJson = gson.toJson(getDataRequestBody);
var getDataRequest = HttpRequest.newBuilder() .uri(URI.create(environmentUri + "REST/Notifications/GetData")) .setHeader("Content-Type", "application/json") .setHeader("Authorization", "Bearer "+tokenObj.data.get("Token")) .POST(HttpRequest.BodyPublishers.ofString(getDataRequestBodyJson)) .build();
var getDataResponse = httpClient.send(getDataRequest, HttpResponse.BodyHandlers.ofString());
System.out.println(getDataResponse.body()); }}
class GetTokenResponse { public String success; public String message; public HashMap<String,Object> data;}