Examples of calling API using curl

From Planfix
Revision as of 13:47, 19 June 2024 by Dmitri (talk | contribs)
Jump to: navigation, search

A few simple examples will illustrate how to work with the Planfix API.

Let's assume that we have created the following data and an authorization token in the Account management /Access to API:

WTdNRp.jpg

APIKey = caf929443b5a3d5fa4839 Private key = 5e05b28cc345d4b41c974e1

Adding a comment to a task

(task number 23525 in the test.planfix.com account)

curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' \
-u 583e3bcc38f34a4af6d8deadbeef8e2d:277ebe9f3a5770adeadbeefa2bc3dbb8 \
-d '<request method="action.add">\
<account>test</account>\
<action>\
<task><general>23525</general></task>\
<description>comment text</description>\
</action></request>' \
https://api.planfix.com/xml/

Adding a comment to a task with HTML markup

(task number 23525 in the test.planfix.com account)

curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' \
-u 583e3bcc38f34a4af6d8deadbeef8e2d:277ebe9f3a5770adeadbeefa2bc3dbb8 \
-d '<request method="action.add">\
<account>test</account>\
<action>\
<task><general>23525</general></task>\
<description>string one&lt;br&gt;string two&lt;br&gt;&lt;b&gt;bold text&lt;/b&gt;</description>\
</action></request>' \
https://api.planfix.com/xml/

Adding a comment to a contact

(contact number 12300 in the test.planfix.com account with HTML markup)

curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' \
-u 583e3bcc38f34a4af6d8deadbeef8e2d:277ebe9f3a5770adeadbeefa2bc3dbb8 \
-d '<request method="action.add">\
<account>test</account>\
<action>\
<contact><general>12300</general></contact>\
<description>string one&lt;br&gt;string two&lt;br&gt;&lt;b&gt;bold text&lt;/b&gt;</description>\
</action></request>' \
https://api.planfix.com/xml/

Search for a contact by phone number

(in the test.planfix.com account)

curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' \
-u 583e3bcc38f34a4af6d8deadbeef8e2d:277ebe9f3a5770adeadbeefa2bc3dbb8 \
-d '<request method="contact.getList">\
<account>test</account>\
<pageCurrent>1</pageCurrent>\
<pageSize>10</pageSize>
<filters><filter>\
<type>4003</type>\
<operator>equal</operator>\
<value>123456</value>\
</filter></filters></request>' \
https://api.planfix.com/xml/

Search for a contact by field value (string type)

(with field ID 10123, in the test.planfix.com account) (Field IDs can be determined using the contact.get method for the contact template with this field)

curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' \
-u 583e3bcc38f34a4af6d8deadbeef8e2d:277ebe9f3a5770adeadbeefa2bc3dbb8 \
-d '<request method="contact.getList">\
<account>test</account>\
<pageCurrent>1</pageCurrent>\
<pageSize>10</pageSize>
<filters><filter>\
<type>4101</type>\
<field>10123</field>\
<operator>equal</operator>\
<value>value_fo_find</value>\
</filter></filters></request>' \
https://api.planfix.com/xml/

Search for a task by field value (string type)

(with field ID 10123, in the test.planfix.com account) (field IDs can be determined using the task.get method on the task template with this field, filter reference - Planfix API Filter)

curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' \
-u 583e3bcc38f34a4af6d8deadbeef8e2d:277ebe9f3a5770adeadbeefa2bc3dbb8 \
-d '<request method="task.getList">\
<account>test</account>\
<pageCurrent>1</pageCurrent>\
<pageSize>10</pageSize>
<filters><filter>\
<type>101</type>\
<field>10123</field>\
<operator>equal</operator>\
<value>value_fo_find</value>\
</filter></filters></request>' \
https://api.planfix.com/xml/


Go To