Bonjour,
Mon script python (python 3.1) doit appeler un web service pour lui envoyer des paramètres au format JSON.

N'étant pas familier avec JSON, je pensais que le code ci-dessous suffirait mais apparemment le web service ne reçoit rien.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/python3.1 -u
# -*- coding:UTF-8 -*-
 
 
import http.client
import json
 
data = [{'routing_account_id': '00001', 'submit_message_id': '20110330192351111536'}, {'routing_account_id': '00001', 'submit_message_id': '20110330192351624189'}]
 
conn = http.client.HTTPConnection('zzz.z.z.z:80')
conn.request('POST', '/debug_post_json.php', body=json.dumps(data), headers={"Content-type": "application/json", "Accept": "application/json"})
response = conn.getresponse()
print(response.status, response.reason)
data = response.read()
print(data)
conn.close()
Mon appel n'est-il pas bon ?

Merci pour votre aide.