FX Reports API

Introduction

fxreports provides a server based API that allows you to work with your report data in PDF format.

The maximum number of requests is 25 per minute.

Required JSON Data Pairs

Name Description Example

templateID

Report template identifier

"templateID": "z0L0H00000XXxxx"

sobjectId

sObject from which the report is built

"sobjectId":"z0T0H00002xxXx3",

token

A valid access token from a bearer token request

id

A valid Salesforce login identifier

See id example.

instance

Your org domain

"instance":"https://xx00.salesforce.com"

Examples

Example 1. Using token
"access_token":"00Di0000000el6B!XXXXQLLxx33PetX4nbVhLV6UmXXXbQZ8GV6Un0zXf.fa5fXX4XXjOih8pX9I88Xn.xx52xxxO7K_T2HIuUVxXXXqu1L5bXXX"
Example 2. Using id
"id":"https://login.salesforce.com/id/00Di0000000el2XXXX/005i0000001XXdjXXX"

Endpoints

The FXReports API provides several endpoints for working with PDFs.

App URL Example

/info

Returns information about the template and the sObject.

To format output with a JSON query, you must have a JSON query tool installed for your operating system.

/handlebars

Review markup after handlebars syntax has been applied

/deepload

See template with data loaded

/render

Render the PDF file, such as to save locally

Token Request

A token is required to utilize the API.

Example 3. Token request, in curl
curl -X POST -F "grant_type=password" -F
"client_id=3XXX9A2xX3Xx17xx6xxxX0XXxxF08kKNujly9Ab8N5e_J8xXXX2d8j3XXxXxXXcewrlXxX6LkgXXXbg2dXXX"
-F "client_secret=1234567890123456789" -F "username=myuser@mydomain.com"
-F "password=xxxxxxxxx"
https://login.salesforce.com/services/oauth2/token

The resulting output would look something like:

 {
   "access_token":"00Di0000000el2B!AQUAQLLek33PetX4xxXxXX6XxXXXbXX8XX6Xx0xXx.xx5fXX4XXxOxx8xX9I88Xx.xx52xxxO7X_T3XXuXXxXXXqu1X5xXXX",

   "instance_url":"https://xx00.salesforce.com",

   "id":"https://login.salesforce.com/id/00Xi0000000xl2XXXX/009x0000001XXxxXXX",

   "token_type":"Bearer",

   "issued_at":"1234123412341",

   "signature":"XX2xxx..."

 }

Merge Endpoint

You can combine multiple items into one PDF file with the /merge endpoint.

Example 4. Endpoint, in curl:
curl -X POST -H "Content-Type: application/json" -d '{ "files":[{ "type": "image", "id":"00X1X000001X1xx"}, {"type":"image", "id":"00P1X000001X1xx"}, {"type":"attachment", "id":"00PS0000003Xx6x"}] "token":"XXXXXC5XAkYJ30XxXxnXXXXX7XxXxoV118xxx9avg5XX3u7xXXxXXoXxX.XXXXXnXXXxXX_G23xX9f9XX12Xxx.oT9xxxxxx", "id":"https://test.salesforce.com/id/00D1F000000X7x8XXX/0051F000002x8xxXXX", "instance":"https://xxxx-xxxxx-0000.xx00.my.salesforce.com"}' https://fxreports.herokuapp.com/merge > test.pdf