gpt4 book ai didi

salesforce - 在Apex中使用HTTP POST设置参数

转载 作者:行者123 更新时间:2023-12-04 05:31:33 24 4
gpt4 key购买 nike

我正在尝试使用Apex设置POST内容。下面的示例使用GET设置变量

  PageReference newPage = Page.SOMEPAGE;
SOMEPAGE.getParameters().put('id', someID);
SOMEPAGE.getParameters().put('text', content);

有什么办法可以将HTTP类型设置为POST?

最佳答案

是的,但是您需要使用HttpRequest类。

String endpoint = 'http://www.example.com/service';
String body = 'fname=firstname&lname=lastname&age=34';
HttpRequest req = new HttpRequest();
req.setEndpoint(endpoint);
req.setMethod('POST');
req.setbody(body);
Http http = new Http();
HTTPResponse response = http.send(req);

有关更多信息,请引用 Salesforce documentation

关于salesforce - 在Apex中使用HTTP POST设置参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17353874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com