4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

マネーフォワードクラウド経費APIβを使ってみる

Posted at

経費の申請

休み明けに経費の申請が止まっているとの連絡がきました。
確かに止まってます。まったく気が付かなかった・・
ステータスを確認して「何か」が連絡してほしいなぁっということで何かないかと見てみると!

For Developer
API連携 β (開発者向け)

という、イイものを見つけました。

MFクラウド経費API β

https://expense.moneyforward.com/api/index.html
ドキュメントもしっかりある!しかもSwaggerで!えらい!ということで使ってみます。

アプリケーション登録

アプリケーション一覧で、アプリケーションの作成ボタンをクリック
フォームに必要な情報を入力し、利用規約に同意して作成ボタンをクリック
Client IDとClient Secretが発行されました。
楽ちんです:grin:

認証

https://expense.moneyforward.com/api/index.html で確認できるので、Authorizeしてみます。
Authorized.PNG

Authorizedになりました。

確認1

試打の office 事業所一覧でテスト

Server response Code 200
Response.json
"offices": [
    {
      "id": "----------------------",
      "identification_code": "-------",
      "office_type_id": -,
      "name": "アステリア株式会社"
    }
  ]

確認2

試打の ex_report 自分の申請リストでもテストしてみます
必須項目がoffice_idなので入力します。

Server response Code 403 Error:Forbidden

動きません。
自分に権限がないだけかと疑い社内管理者に問い合わせるも、問題なし。

あきらめかけるも
「確認1」の事業所一覧で取得した id が妙に長いことを発見

取得した値を使ってみます → 申請リスト取得成功

「office_id - 事業所id」とか書いてあるから4桁-4桁のあの番号かと思ったけど、違うみたいです。

ともあれ、取得内容を見てみると

Response.json
"ex_reports": [
  {
    "id": "----------------------",
    "ex_report_type_id": "----------------------",
    "office_member_id": "----------------------",
    "status": "approved",
    "title": "12月 交通費",
    "number": ----,
    "submitted_at": "2018-12-13T00:00:00.000+09:00",
    "approved_at": "2018-12-13T01:00:00.000+09:00",
    "created_at": "2018-12-13T00:00:00.000+09:00",
    "updated_at": "2018-12-13T01:00:00.000+09:00"
  },

statusが違う・・・

statusは下記のような値が返ってくるはずなので、
この申請は「paid:支払済み」が返ってきてほしいが「approved:承認済み」が返ってきてる

意味
unsubmitted 下書き
waiting_step_one 第一承認待ち
waiting_step_two 第二承認待ち
waiting_step_three 第三承認待ち
waiting_step_four 第四承認待ち
waiting_step_five 第五承認待ち
approved 承認済み
paid 支払済み
canceled 取消済み
rejected 却下済み

さらに、支払日も取得できないことに気が付く
もしかして、支払日ってカスタマイズしたのか?と思い、再度社内管理者へ問い合わせるも、カスタマイズしてないとのこと

ムムムやりたい事はできなさそう:confounded:

今日のところは終了となりました。

4
1
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?