gpt4 book ai didi

salesforce - 无法使用 Apex 访问在 force.com 平台上构建的 RESTful 服务

转载 作者:行者123 更新时间:2023-12-03 09:45:12 28 4
gpt4 key购买 nike

我在 Force.com 上使用 Apex 创建了一个 RESTful 服务,下面是我的代码。

@RestResource(urlMapping='/helloWorld/*')
global with sharing class RestWebservice {

@HttpGet
global static String helloWorld(){
return 'HelloWorld';
}

}

我正在尝试使用以下网址访问我的 RESTful 服务:
https://ap1.salesforce.com/services/apexrest/helloWorld/

作为回应,我得到:
HTTP/1.1 404 Not Found
Date:Thu, 18 Jul 2013 07:35:44 GMT
Content-Length:96
Content-Type:application/json;charset=UTF-8

[
{
"message": "Could not find a match for URL /helloWorld/",
"errorCode": "NOT_FOUND"
}
]

以下是我的类快照:
enter image description here

enter image description here

我该如何解决这个问题?任何帮助表示赞赏。

最佳答案

当你把 *(星号)放在最后时,你需要写一个 Id 或其他东西,而不是像这个 document 中描述的那样。 .
你想要完成的事情我想更像是这样

 @RestResource(urlMapping='/helloWorld')

然后打这个电话
curl -H "Authorization: Bearer sessionId"  "https://instance.salesforce.com/services/apexrest/helloWorld"

关于salesforce - 无法使用 Apex 访问在 force.com 平台上构建的 RESTful 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17717605/

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