我正在尝试阅读Flask的回复。参数是通过Apex方法传递的。
public void savePro(){
String jsonData = readcsvFile();
String name_dev = 'AAAA';
String email_dev = 'BBBB';
String selected_project_list = 'CCCC';
String selected_org_list = 'DDDD';
jsonData = '[[{"name":"'+name_dev+'"},{"email":"'+email_dev+'"},{"project":"'+selected_project_list+'"},{"org":"'+selected_org_list+'"}]';
String endpoint = 'https://temp.pythonanywhere.com/query-example';
HttpRequest req = new HttpRequest();
req.setEndpoint(endpoint);
req.setHeader('Accept', 'application/json');
req.setMethod('POST');
req.setbody(jsonData);
Http http = new Http();
HTTPResponse response = http.send(req);
}
Python代码:
from flask import Flask, request
from simple_salesforce import Salesforce
import json,time
app = Flask(__name__)
@app.route('/query-example', methods=['POST'])
def query_example():
temp = str(request.form)
温度值为
ImmutableMultiDict([('[[{"name":"AAAA"},{"email":"BBBB"},{"project":"CCCC"},{"org":"DDDD"}]', '')])
我想要Json格式。不知道为什么在ImmutableMultiDict中。请帮助我。