User Manual

08.14.2024

MANUAL

Developer Function: API: Group Operation: Import

## Overview Import group information using API. ## Preparation Please [Create an API Key](/manual/api-key) before performing API operations. ## Request Send CSV data and JSON parameters using the request format below. |Setting item|Value| |:--|:--| |HTTP Method|POST| |Content-Type |multipart/form-data| |Character Code|UTF-8| |URL|http://{server name}/api/items/{site ID}/import (*1)| |Body|Refer to "Items to Specify for Body" below| (*1) Please edit the {server name} part suit your environment as appropriate. ### Items to Specify for Body |Item name|Value| |:--|:--| |parameters|Specify the contents of the "API Parameters" below as a JSON format string| |file|Binary data of the CSV file to be registered| ### API Parameters |Item name|Example setting|Notes| |:--|:--|:--| |ApiVersion|1.1|API version| |ApiKey|3da0fa3a7R61faf821...|Acquired API key| |Encoding|Shift-JIS|CSV file encoding. Specify "UTF-8" or "Shift-JIS"| |ReplaceAllGroupMembers|true|Specify whether to "Delete Members before Importing." If true is specified, all members of groups that match the group ID in the CSV file will be deleted before importing. | ## Execution Example Sample ### PowerShell (version 6.0 or later) Sample ##### PowerShell ``` $uri = 'http://servername/api/groups/import' $filePath = "./sample.csv" $form = @{ parameters = ConvertTo-Json @{ ApiVersion = 1.1; ApiKey = "4d84b4773a58bbc3c4..."; Encoding = "UTF-8"; }; file = Get-Item -Path $filePath; } Invoke-WebRequest -Uri $uri -Method Post -Form $form ``` ### Python Sample ##### Python ``` import requests import json url = "https://servername/api/groups/import" filePath = "./sample.csv" data = { "parameters": json.dumps({ "ApiVersion" : 1.1, "ApiKey" : "4d84b4773a58bbc3c4...", "Encoding" : "UTF-8" }) } files = { "file":("sample.csv", open(filePath,"rb"), "text/csv") } response = requests.post(url, data, files=files) print(response.content.decode()) ``` ## Response The json data in the following format will be returned. ##### JSON ``` { "Id":0, "StatusCode":200, "Message":"50 items added and 12 items updated." } ``` ## Confirmation Items in Case of Error [・Precautions when using the API and things to check if an error occurs](/manual/faq-api) [・FAQ: What to check if modified configuration files or API requests (JSON format) are not recognized correctly](/manual/faq-json-format)
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.