0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PythonでPleasanterと連携(単純な全件Select)

0
Posted at

単純にPythonからPleasanterにレコード取得できるか確認
備忘録として記載

import requests
import json

pleasanter_ipadd = 192.168.0.0
site_id = サイトID(int)
url = f"http://{pleasanter_ipadd}/api/items/{site_id}/get"

#状況欄指定やDateAを昇順
payload = {
    "ApiVersion": 1.1,
    "ApiKey": "プリザンターのユーザー欄からAPIKey作れます",
    "View": {
        "ColumnFilterHash": {
            "Status": "[\"100\",\"200\"]"
        },
        "ColumnSorterHash": {
            "DateA": "asc"
        }
    }
}

response = requests.post(url, json=payload)

# レスポンスを JSON 化
data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))

# StatusCode チェック
if data.get("StatusCode") != 200:
    print("API Error:", data)
    exit()

# Data を取り出す
items = data["Response"]["Data"]

# 1レコードずつ表示
for item in items:
    print("---- Record ----")
    print("ResultId:", item["ResultId"])
    print("Title:", item["ItemTitle"])
    print("Status:", item["Status"])
    print("ClassA:", item["ClassHash"].get("ClassA")) #そのまま取れるの簡単でいい
    print("DescriptionA:", item["DescriptionHash"].get("DescriptionA"))
    print("UpdatedTime:", item["UpdatedTime"])
    print()

職場だとPHPでやってたけど
PythonだとJson形式の内部のデータが簡単に取れていいですね。
次はinsertを作りたいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?