> For the complete documentation index, see [llms.txt](https://tailieu.smax.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tailieu.smax.ai/bot-auto/the-chuc-nang/the-nang-cao/jsonapi.md).

# JsonAPI

Thẻ **JsonAPI** dùng để gọi tới 1 API và lưu lại response của API đó vào các thuộc tính

{% hint style="danger" %}
Để sử dụng card JsonAPI, bạn cần tìm hiểu kĩ tài liệu về API của nền tảng muốn sử dụng
{% endhint %}

Thẻ JsonAPI hỗ trợ 4 phương thức: GET, POST, PUT, DELETE

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2FdFU2amm3CjYxq8AYUznW%2Fimage.png?alt=media&amp;token=415f8122-5ef7-4206-9ca8-bea89cba8960" alt=""><figcaption></figcaption></figure>

Sau khi chọn phương thức, nhập URL của API vào dòng Nhập URL

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2FUD3Nc19g4RagU1Fge7Un%2Fimage.png?alt=media&amp;token=9aaed18e-f234-4c27-8cfc-412071829693" alt=""><figcaption></figcaption></figure>

Bạn có thể thêm các Headers (nếu có) vào phần tiêu đề, ví dụ như Authorization, content-type,...

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2F1R483gFZqyWUKUcqxaGt%2Fimage.png?alt=media&amp;token=c7a967bf-5abb-4339-9a32-5a69a479e55d" alt=""><figcaption></figcaption></figure>

Thẻ JsonAPI hỗ  trợ 2 loại content-type là **multipart/form-data** và **json** (chỉ áp dụng cho phương thức POST và PUT)

Với content-type là multipart/form-data, bạn chọn Body là PARAMS, sau đó nhập key và value vào 2 cột Tên và Giá trị

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2FWg2eA4nPrVFHVZUVwqz8%2Fimage.png?alt=media&amp;token=ab1e4464-03c1-417e-8d16-2bf98bc61ab9" alt=""><figcaption></figcaption></figure>

Với content-type là json, bạn chọn Body là JSON, sau đó nhập mã Json vào Body

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2FMKwJGMqpwKZ8eaTCeon1%2Fimage.png?alt=media&amp;token=579b2c5d-7891-4d52-944a-d478463f4645" alt=""><figcaption></figcaption></figure>

Sau khi nhập xong thông tin API, bạn có thể chạy test bằng cách chọn page và nhập pid của tài khoản Facebook muốn test, sau đó chọn Chạy thử API

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2FtzkbSngw6WXCimQIf188%2Fimage.png?alt=media&amp;token=18658b6b-658e-4981-925b-27d160bc59a7" alt=""><figcaption></figcaption></figure>

Bạn có thể nhập đường dẫn JSON dẫn tới key muốn lưu giá trị vào attribute trên SmaxAi, sau đó chọn thuộc tính để lưu value

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2F1l7zoL1Xkq7AWP4f8Rd6%2Fimage.png?alt=media&amp;token=0f798589-26c0-4b97-bd5c-d3966ce2b046" alt=""><figcaption></figcaption></figure>
