NAV

Status Report(Last Updated : 01/04/2017)

Report resource provides status report of a request.

Methods

GET /rest/v1/{user_name}/report/{request_id}

GET Status Report

Retrieve the status of a request by providing the request ID. A successfully processed request will return the results of the request. If the request is currently being processed or has failed, a message indicating so will be returned.

Resource Information

Response Formats JSON
Allowed Methods GET
URL http://api.trumpia.com/rest/v1/{user_name}/report/{request_id}
{user_name} Your account username (this can be found in the Account Settings page after logging in.)
{request_id} The request ID is returned by any request sent to the API.

Header Parameters

* required parameters
Parameter Description
Content-Type * application/json
X-Apikey * Your API key (This can be found in the API Settings page after logging in.)

Example value: 123456789abc1011

Code sample for GET Status Report

"Request Example:
GET http://api.trumpia.com/rest/v1/{user_name}/report/{request_id}"

"Response Example:"
{
  "request_id" : "1234561234567asdf123",
  "list_id" : "987987987980"
}


<?
	// GET Status Report - Report resource provides status report of a request.
	include "request_rest.php";

	$request_url = "http://api.trumpia.com/rest/v1/{user_name}/report";
	$request_id = "1234561234567asdf123";
	$request_url =	$request_url . "/" . $request_id;

	$request_rest = new RestRequest();

	$request_rest->setRequestURL($request_url);
	$request_rest->setAPIKey("{api_key}");
	$request_rest->setMethod("GET");
	$result = $request_rest->execute();

	$response_status = $result[0];
	$json_response_data = $result[1];

	if ($response_status == "200") {	//success
		echo $json_response_data;
	} else {
		echo $response_status ." - connection failure";
	}
?>


// GET Status Report - Report resource provides status report of a request.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>Report Get Sample Code</title>
<body>

<%
	String requestId = "1234561234567asdf123";
	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/report/" + requestId;

	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// GET Status Report - Report resource provides status report of a request.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class ResultData
    {
        public JObject result { get; set; }
    }
    class ReportGet
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.BaseAddress = new Uri("http://api.trumpia.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var requestId = "1234561234567asdf123";

                //GET
                HttpResponseMessage response = await client.GetAsync(string.Format("/rest/v1/{0}/report/{1}", username, requestId));
                if (response.IsSuccessStatusCode)
                {
                    var resultInfo = await response.Content.ReadAsStringAsync();
                    string json = JsonConvert.SerializeObject(resultInfo);
                    Console.WriteLine(json);
                }
            }
        }
    }
}