基本カレンダーに予定作成でSERVICE_UNAVAILABLEが出力される

rs_a95fdd

2022.08.29既読 1025

基本カレンダーに予定作成したときにSERVICE_UNAVAILABLEが出力されてしまいます。


AccountIdの変換 OR icsデータに不備があるのかと思い調査しているのですがわからないため
解決方法についてご教示いただけないでしょうか。
コードに不備がありましたら申し訳ございません。

■接続言語 python

■出力結果

{'code': 'SERVICE_UNAVAILABLE', 'description': 'Service failure'}
<Response [500]>
■以下コードになります。

client_id = 'eeee'
client_secret = 'dddd'
service_account_id = 'ccc@exmple'
privatekey = 'bbb'
AccountId = 'aaa@exmple'
scope = 'calendar'
def get_access_token(client_id, client_secret_txt, scope, jws):
   url = '{}/token'.format(BASE_AUTH_URL)
   headers = {
       'Content-Type': 'application/x-www-form-urlencoded'
   }
   params = {
       "assertion": jws,
       "grant_type": urllib.parse.quote("urn:ietf:params:oauth:grant-type:jwt-bearer"),
       "client_id": client_id,
       "client_secret": client_secret_txt,
       "scope": scope,
   }
   form_data = params
   r = requests.post(url=url, data=form_data, headers=headers)
   return r
def get_jwt(client_id, service_account_id, privatekey):
   current_time = datetime.datetime.now().timestamp()
   iss = client_id
   sub = service_account_id
   iat = current_time
   exp = current_time + (60 * 60)
   jws = jwt.encode(
       {
           "iss": iss,
           "sub": sub,
           "iat": iat,
           "exp": exp
       }, privatekey, algorithm="RS256")
   return jws
def CalendareventS(jwt_txt,CalendarId,**EventParams):
   apiurl = apiurl + urllib.parse.quote(AccountId)
   apiurl = apiurl + '/calendar/events'
   
   header = {
       'Authorization' : 'Bearer {}'.format(jwt_txt),
       'Content-Type' : 'application/json; charset=UTF-8'
   }
   r = requests.post(apiurl, headers = header, json = EventParams)
   return r
def main():
   jwt_txt = get_jwt(client_id,service_account_id,privatekey)
   get_Jwt_j = get_access_token(client_id,client_secret,scope,jwt_txt)
   get_jwt_txt = get_Jwt_j.json()['access_token']
    
   f = open('C:/CalendarFile.ics',encoding='utf_8')
   eventdata = f.read()
   eventdata = eventdata.replace('\\r\\n','\r\n')
   eventdata = json.dumps(eventdata)
   f.close()
   event = CalendareventS(get_jwt_txt,'defaultCalendarId',ical=eventdata)
   print(event)
if __name__ == '__main__':
   main()

コメント1

  • 업데이트 된 답글입니다.

    rs_a95fdd 投稿者

    度々ですみません。自己解決しました。
    api1.0と異なり、icsファイルをjsonにするのではなく、
    パラメータに合わせてjson作成⇒連携で連携出来ました。

    2022.08.30

    0
前の投稿 VB.NETからのメッセージ送信について
次の投稿mustReadDaysについて
リスト

まだ、解決できませんか?
今すぐ実際に使用しているLINE WORKSユーザーに質問してみましょう。