· 2 years ago · May 29, 2023, 04:11 PM
1import requests
2
3url = "http://inforisk-api.infomarket.ma/api/login"
4login_data = {
5 "cliLogin": "odoo_sonic_test",
6 "cliPasswordClair": "128738720927"
7}
8
9response = requests.post(url, json=login_data)
10
11if response.status_code == 200:
12 print("Login successful!")
13 print("Response:")
14 print(response.json())
15else:
16 print("Login failed. Status code:", response.status_code)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34{
35 "info": {
36 "_postman_id": "1e1b9b1e-71ef-4c70-9dd7-a934241a2330",
37 "name": "Inforisk API",
38 "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
39 },
40 "item": [
41 {
42 "name": "http://inforisk-api.infomarket.ma/api/login",
43 "request": {
44 "method": "POST",
45 "header": [
46 {
47 "key": "content-type",
48 "value": "text/plain;charset=UTF-8",
49 "type": "default"
50 }
51 ],
52 "body": {
53 "mode": "raw",
54 "raw": "{\n \"cliLogin\": \"odoo_sonic_test\",\n \"cliPasswordClair\": \"128738720927\"\n}",
55 "options": {
56 "raw": {
57 "language": "json"
58 }
59 }
60 },
61 "url": {
62 "raw": "http://inforisk-api.infomarket.ma/api/login",
63 "protocol": "http",
64 "host": [
65 "inforisk-api",
66 "infomarket",
67 "ma"
68 ],
69 "path": [
70 "api",
71 "login"
72 ]
73 }
74 },
75 "response": []
76 },
77 {
78 "name": "http://inforisk-api.infomarket.ma/api/public/entreprise",
79 "request": {
80 "auth": {
81 "type": "bearer",
82 "bearer": [
83 {
84 "key": "token",
85 "value": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJPZG9vIEJpbE1TIE90aG1hbmUgUmVyaGF5ZSIsImV4cCI6MTY2MzI1ODk3NSwiYXV0aG9yaXRpZXMiOltdLCJjbGlJZCI6MTAwMDAwMCwiY2xpRW1haWwiOiJzdC5zb25pY0BnbWFpbC5jb20iLCJjbGlzb2NJZCI6MTAwMDAwMH0.It9aquNk4dhGMn8Yi0BppgxxzFmWmiJ6VVwu5oc_Zm0",
86 "type": "string"
87 }
88 ]
89 },
90 "method": "POST",
91 "header": [
92 {
93 "warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
94 "key": "Authorization",
95 "value": "Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJPZG9vIEJpbE1TIE90aG1hbmUgUmVyaGF5ZSIsImV4cCI6MTY2MzMyMTgwNCwiYXV0aG9yaXRpZXMiOltdLCJjbGlJZCI6MTAwMDAwMCwiY2xpRW1haWwiOiJzdC5zb25pY0BnbWFpbC5jb20iLCJjbGlzb2NJZCI6MTAwMDAwMH0.1tmpyv0_FeRKILjTIObxMnDyosPb6MDq8JiHkqGqvxI",
96 "type": "default"
97 }
98 ],
99 "body": {
100 "mode": "raw",
101 "raw": "{\n \"denomination\" : \"inforisk\"\n}",
102 "options": {
103 "raw": {
104 "language": "json"
105 }
106 }
107 },
108 "url": {
109 "raw": "http://inforisk-api.infomarket.ma/api/public/entreprise",
110 "protocol": "http",
111 "host": [
112 "inforisk-api",
113 "infomarket",
114 "ma"
115 ],
116 "path": [
117 "api",
118 "public",
119 "entreprise"
120 ]
121 }
122 },
123 "response": []
124 }
125 ]
126}