Personal tools

Difference between revisions of "Web API"

From TrueERP wiki

Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<menu align="center" name="myMenu">
+
<menu name="myMenu" align="center">
 
More Detail=
 
More Detail=
 
[[Audit Trail List]]
 
[[Audit Trail List]]
Line 10: Line 10:
 
[[Setup Docs Path]]
 
[[Setup Docs Path]]
 
[[Utilities Reports]]
 
[[Utilities Reports]]
 +
[[Web API Examples]]
 
</menu>  
 
</menu>  
  
 
== Overview  ==
 
== Overview  ==
  
'''Creating the communication link'''
+
'''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"  
 
'''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"  
Line 21: Line 22:
  
 
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"  
 
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"  
 +
 +
<br>
  
 
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]  
 
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/erpapi/TCustomer/114
+
or using the samples above [[Web API Examples|https://Server1/Sample_Company/TCustomer]]
  
This will give you all of the details for customer 114 in the "Sample_Company" on "Server1"  
+
This will give you a list of all of the customer in "Sample_Company" on "Server1"<br>
  
or using the samples above https://Server1/Sample_Company/TCustomer  
+
or using the samples above [[Web API Examples|https://Server1/erpapi/TCustomer/5]]
  
This will give you a list of all of the customer in "Sample_Company" on "Server1"  
+
This will give you all of the details for customer 5 in the "Sample_Company" on "Server1"  
 +
 
 +
<br>
  
 
To write data back to ERP send a HTTP POST command using the following format: https://[server name]/erpapi/[resource name]  
 
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/TCustomer
+
or using the samples above [[Web API Examples|https://Server1/Sample_Company/TInvoice]]
  
This will create a new customer in "Sample_Company" on "Server1"  
+
This will create a new Invoice in "Sample_Company" on "Server1"  
  
or using the samples above https://Server1/Sample_Company/TCustomer/114
+
or using the samples above [[Web API Examples|https://Server1/Sample_Company/TInvoice/1768]]
  
This will edit customer 114 in the "Sample_Company" on "Server1"  
+
This will edit Invoice 1768 in the "Sample_Company" on "Server1"  
 +
 
 +
<br>
  
 
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.  
 
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.  
Line 46: Line 53:
 
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.  
 
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 customer:  
+
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 } }
 +
 
 +
<br>
 +
 
 +
'''Suggested websites for more information on Ports and Forwarding:'''<br>
 +
 
 +
http://serverfault.com/questions/26564/how-to-check-if-a-port-is-blocked-on-windows
 +
 
 +
http://www.t1shopper.com/tools/port-scan/
  
{ "type":"TCustomer", "fields": { "ID":115 } }
+
http://www.yougetsignal.com/tools/open-ports/<br>
  
 +
<br>
  
 +
<br>
  
'''What is a HTTP request http://djce.org.uk/dumprequest'''
+
'''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'''
 
'''Example of the HTTP request for Visual Studio http://www.codeproject.com/KB/IP/httpwebrequest_response.aspx'''

Latest revision as of 15:48, 24 August 2012

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