Szkolenie API - EN

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

What is an API?

API:
• Application Programming Interface
• This is how computer programs exchange data and
communicate with each other
• Consists of sets of rules and definitions
Data transferring

Through HTTP:
• POST – most commonly used in the SALESmanago API, it sends data from
a client to a server (in JSON form) e.g. sending data from a contact form to
SALESmanago.

• GET - sends parameters through a URL address. With this a certain


application state can remain consistent e.g. a language version of a website
Authentication
Done by:

• apiKey – a random string of characters, can be different for each


request, used for sha generating

• requestTime – time of the request in milliseconds (since 01.01.1970),


you can check it at http://currentmillis.com/

• Sha – a hashed combination of apiKey + clientId + apiSecret, you can


generate it at http://www.sha1-online.com/
Contact upsert
1. What does it do?
• t adds new contacts or modifies existing ones based on their email
addresses. Uses the POST method.

2. What arguments does it take?


• an email address (obligatory)
• other parameters to assign to a contact (optional)

3. What values it returns?


• an ID of created or modified contact
Contact upsert
Add External Event
1. What does it do??
• It adds an external event based on a contact’s email address. Uses the
POST method.

2. What arguments does it take?


• a contact’s email address

• an external event with its parameters (description, price, date, product)

3. What values does it return?


• an ID of created event

ATTENTION, this method adds an event to a contact that already exists in


the system, it DOES NOT create a new contact!
Add External Event
Common mistakes
• Incorrect clientId, sha or request time (response: „Not authenticated”)

• syntax or JSON structure errors; a missing comma, colon, semicolon etc.


(Status 400 Bad Request)

• the request sent to a wrong instance, e.g. a client from app3 sends a
request to http://www.salesmanago.pl/api/contat/upsert instead of
http://app3.salesmanago.pl/api/contat/upsert

• Adding an external event without creating a contact first (commonly due


to a queue)
Useful links
1. JSON structure parser: http://json.parser.online.fr/

2. Sha generating: http://www.sha1-online.com/

3. requestTime generating: http://currentmillis.com/

4. Firefox plugin for sending request:


https://addons.mozilla.org/pl/firefox/addon/httprequester/

5. Chrome plugin for sending request :


https://chrome.google.com/webstore/detail/advanced-rest-client/hgmlo
ofddffdnphfgcellkdfbfbjeloo

6. Our API documentation:


http://files.salesmanago.pl/up/integration/en/SALESmanago%20-%20
API%20(en).pdf

You might also like