Personal tools

Web API

From TrueERP wiki

Jump to: navigation, search

Overview

Creating the communication link

First step is to create a user, with a password inside the required ERP Data file such as the "Sample_Company" file. This user is what the web API will use to connect to the ERP database. Typically you would create in ERP a user called "WebUser" with a Password like "WebUser"

Second step from within the software development environment that you are working in, use their HTTPS component or library to send requests to the ERP Web API.

Inside this HTTPS component or library the request must contain: - a HTTP request Username that matches the ERP Username ie "WebUser" - a HTTP request Password that matches the ERP Password ie "WebUser" - HTTP request custom headers must have a "database" value containing the name of the ERP database ie "Sample_Company"


To read data from the ERP Web API send a HTTP GET command using the following format: https://[server name]/erpapi/[resource name]/[optional resource ID]

or using the samples above https://Server1/Sample_Company/TCustomer

This will give you a list of all of the customer in "Sample_Company" on "Server1"

or using the samples above https://Server1/erpapi/TCustomer/5

This will give you all of the details for customer 5 in the "Sample_Company" on "Server1"


To write data back to ERP send a HTTP POST command using the following format: https://[server name]/erpapi/[resource name]

or using the samples above https://Server1/Sample_Company/TInvoice

This will create a new Invoice in "Sample_Company" on "Server1"

or using the samples above https://Server1/Sample_Company/TInvoice/1768

This will edit Invoice 1768 in the "Sample_Company" on "Server1"


If the request JSON object does not contain an ID the API will attempt to create a new instance of that particular object. If the request JSON object does contain an ID the API will attempt to update the existing ERP object with the JSON data provided in the POST.

API Request Results. All requests will return a HTTP respone of 200 if no errors where encountered. If an error occures a non 200 code will be returned and the HTTP responce custom headers will contain a "errormessage" value.

When adding a new object (HTTP POST) the responce body JSON contains the ID of the newly created object, eg after adding a new Invoice:

{ "type":"TInvoice", "fields": { "ID":1768 } }


Suggested websites for more information on Ports and Forwarding:

http://serverfault.com/questions/26564/how-to-check-if-a-port-is-blocked-on-windows

http://www.t1shopper.com/tools/port-scan/

http://www.yougetsignal.com/tools/open-ports/



What is a HTTP request http://djce.org.uk/dumprequest

Example of the HTTP request for Visual Studio http://www.codeproject.com/KB/IP/httpwebrequest_response.aspx