Lambda

Python3でリクエストパラメータ付のPOST通信をしたときに、リクエストパラメータが抜け落ちる

tkfric.hatenablog.com この記事でやったことの続き def http_post(url, headers, body): req = urllib.request.Request(url, json.dumps(body).encode(), headers, 'POST') try: with urllib.request.urlopen(req) as res: body = res.read().decode() でbo…

can't concat bytes to str: TypeErrorを解決する

コードは以下 def http_post(url, headers, body): req = urllib.request.Request(url, body, headers, 'POST') try: with urllib.request.urlopen(req) as res: body = res.read().decode() でてきたエラーは以下 can't concat bytes to str: TypeError Tra…

LambdaでHTTPリクエストしたときに遭遇したやつ

Lambdaから外部のAPIを叩いてたときに遭遇した <urllib.request.Request object at 0x7faa06fe2278> サンプルコードは以下 def http_post(url, headers, body): method = 'POST' data = urllib.parse.urlencode(body).encode() req = urllib.request.Request(url, data, headers, method) try: with urllib.req</urllib.request.request>…