我目前正在尝试在 Salesforce 中创建一个 RESTful API,但我在 iOS 部分遇到了一些问题。这是我一直在尝试使用的快速代码,但是我收到 NOT_FOUND 404 错误消息,“请求的资源不存在。”
let getRequest: SFRestRequest = restAPI.performRequestWithMethod(SFRestMethodGET, path: "/services/apexrest/(service name here)/", queryParams: nil, failBlock: {
error in
println(error)
}, completeBlock: {
response in
println(response)
})
我可以让其他 SOQL 查询在我的 iOS 应用程序中工作,并且用户可以正常登录,我想我在调用我的 Apex 网络服务方面可能有点偏离。
非常感谢任何建议/评论!谢谢!
最佳答案
最终的解决方案是
var request = SFRestRequest(method: SFRestMethodGET, path:"/services/apexrest/CustomRestWebservice/", queryParams:nil)
request.endpoint = ""
restAPI.sendRESTRequest(request, failBlock: {error in println(error)}, completeBlock: { response in println(response) })
端点默认为一个不是您想要的字符串,因此您必须手动将其设置为空才能获得正确的结果。
关于ios - 将 SFRestAPI 与 Swift 结合使用的 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30269971/