Examples of calling API using curl

From Planfix
Revision as of 14:03, 19 June 2024 by Dmitri (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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:

gkoYwa.jpg

APIKey = caf9e72923b5a3d5fa48399

Authorization token = 2e21b0cc82756f0554a6f4d

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:Task filters)

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