Personal tools

Difference between revisions of "Web API"

From TrueERP wiki

Jump to: navigation, search
(Created page with "<menu align="center" name="myMenu"> More Detail= Audit Trail List Backup Company Information Export to Report DB Multi-site Preferences Restore [[Setu...")
 
 
(7 intermediate revisions by 2 users 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  ==
  
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"
+
'''Creating the communication link'''
  
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.  
+
'''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"  
+
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:
+
'''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.
https://[server name]/erpapi/[resource name]/[optional resource ID]
+
  
or using the samples above
+
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"
https://Server1/erpapi/TCustomer/114
+
  
This will give you all of the details for customer 114 in the "Sample_Company" on "Server1"
+
<br>
  
or using the samples above
+
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]
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 [[Web API Examples|https://Server1/Sample_Company/TCustomer]]
  
To write data back to ERP send a HTTP POST command using the following format:
+
This will give you a list of all of the customer in "Sample_Company" on "Server1"<br>
https://[server name]/erpapi/[resource name]
+
  
or using the samples above  
+
or using the samples above [[Web API Examples|https://Server1/erpapi/TCustomer/5]]
https://Server1/Sample_Company/TCustomer
+
  
This will create a new customer in "Sample_Company" on "Server1"
+
This will give you all of the details for customer 5 in the "Sample_Company" on "Server1"  
  
or using the samples above
+
<br>
https://Server1/Sample_Company/TCustomer/114
+
  
This will edit customer 114 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]
  
If the request JSON object does not contain an ID the API will attempt to create a new instance of that particular object.
+
or using the samples above [[Web API Examples|https://Server1/Sample_Company/TInvoice]]
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.
+
This will create a new Invoice in "Sample_Company" on "Server1"  
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:
+
or using the samples above [[Web API Examples|https://Server1/Sample_Company/TInvoice/1768]]
  
{
+
This will edit Invoice 1768 in the "Sample_Company" on "Server1"  
"type":"TCustomer",
+
"fields":
+
{
+
"ID":115
+
}
+
}
+
  
What is a HTTP request
+
<br>
http://djce.org.uk/dumprequest
+
  
Example of the HTTP request for Visual Studio
+
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.
http://www.codeproject.com/KB/IP/httpwebrequest_response.aspx
+
 
 +
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 } }
 +
 
 +
<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/
 +
 
 +
http://www.yougetsignal.com/tools/open-ports/<br>
 +
 
 +
<br>
 +
 
 +
<br>
 +
 
 +
'''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'''

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