浏览代码

Content-Type space change

SadhulaSaiKumar 1年前
父节点
当前提交
66fe32e4b0
共有 1 个文件被更改,包括 19 次插入40 次删除
  1. 19
    40
      Demand_forcasting/forcasting2.py

+ 19
- 40
Demand_forcasting/forcasting2.py 查看文件

231
         print(result)
231
         print(result)
232
         result.to_json('forcast.json', orient="records")
232
         result.to_json('forcast.json', orient="records")
233
     
233
     
234
+    
234
         with open('forcast.json', 'r') as json_file:
235
         with open('forcast.json', 'r') as json_file:
235
             json_load = json.load(json_file)
236
             json_load = json.load(json_file)
236
             #url = "https://demo.bizgaze.app/apis/v4/bizgaze/integrations/demandforecast/saveforecast/List"
237
             #url = "https://demo.bizgaze.app/apis/v4/bizgaze/integrations/demandforecast/saveforecast/List"
237
-        url=post_url
238
+            url=post_url
238
     
239
     
239
-        payload = json.dumps(json_load)#.replace("]", "").replace("[", "")
240
+            payload = json.dumps(json_load)#.replace("]", "").replace("[", "")
241
+            print(payload)
240
         #print(payload)
242
         #print(payload)
241
-        headers = {
243
+            headers = {
242
             #'Authorization': 'stat 263162e61f084d3392f162eb7ec39b2c',#demo
244
             #'Authorization': 'stat 263162e61f084d3392f162eb7ec39b2c',#demo
243
             'Authorization': post_url_token,#test
245
             'Authorization': post_url_token,#test
244
-            #'Content-Type': 'application/json'
245
-        }
246
-        response = requests.request("POST", url, headers=headers, data=payload)
247
-        print("##############################################################")
248
-        print(response.text)
246
+            'Content-Type': 'application/json'
247
+            }
248
+            response = requests.request("POST", url, headers=headers, data=payload)
249
+        # print("##############################################################")
250
+            print(response.text)
251
+
249
     
252
     
250
     return 'done'
253
     return 'done'
251
 
254
 
488
         with open('forcast.json', 'r') as json_file:
491
         with open('forcast.json', 'r') as json_file:
489
             json_load = json.load(json_file)
492
             json_load = json.load(json_file)
490
             #url = "https://demo.bizgaze.app/apis/v4/bizgaze/integrations/demandforecast/saveforecast/List"
493
             #url = "https://demo.bizgaze.app/apis/v4/bizgaze/integrations/demandforecast/saveforecast/List"
491
-        url=post_url
494
+            url=post_url
492
     
495
     
493
-        payload = json.dumps(json_load)#.replace("]", "").replace("[", "")
496
+            payload = json.dumps(json_load)#.replace("]", "").replace("[", "")
497
+            print(payload)
494
         #print(payload)
498
         #print(payload)
495
-        headers = {
499
+            headers = {
496
             #'Authorization': 'stat 263162e61f084d3392f162eb7ec39b2c',#demo
500
             #'Authorization': 'stat 263162e61f084d3392f162eb7ec39b2c',#demo
497
             'Authorization': post_url_token,#test
501
             'Authorization': post_url_token,#test
498
-           # 'Content-Type': 'application/json'
499
-        }
500
-        response = requests.request("POST", url, headers=headers, data=payload)
502
+            'Content-Type': 'application/json'
503
+            }
504
+            response = requests.request("POST", url, headers=headers, data=payload)
501
         # print("##############################################################")
505
         # print("##############################################################")
502
-        # print(response.text)
503
-        
504
-        # filePath='path.csv'
505
-
506
-           
507
-        # if os.path.exists(filePath):
508
-        #     print('file exist')
509
-        #     #userdata = pd.DataFrame(data)
510
-        #     result.to_csv('path.csv', mode='a',index=False, header=False)
511
-
512
-        # else:
513
-        #     print("file as it doesn't exists")
514
-        #     #result = pd.DataFrame(data)
515
-        #     result.to_csv('path.csv', index=False)
516
-    
517
-
518
-
519
-    # result=pd.read_csv('path.csv')
520
-    # result.to_json('forcast.json', orient="records")
521
-    # import json
522
-
523
-    # # open the JSON file and read its contents
524
-    # with open(r'forcast.json', 'r') as f:
525
-    #     json_data = json.load(f)
506
+            print(response.text)
526
 
507
 
527
-    # print the JSON data
528
-    #print(json_data)
529
     
508
     
530
     #output={"response":"success","result":json_data}
509
     #output={"response":"success","result":json_data}
531
     #print(output)
510
     #print(output)

正在加载...
取消
保存