Search code examples
iosweb-servicessalesforcesalesforce-ios-sdk

Webservice using SFRestAPI with Swift


I'm currently trying to make a RESTful API in Salesforce and I'm having some issues with the iOS portion. Here's the swift code I've been trying to use, however I'm getting a NOT_FOUND 404 error with the message, "The requested resource does not exist."

let getRequest: SFRestRequest = restAPI.performRequestWithMethod(SFRestMethodGET, path: "/services/apexrest/(service name here)/", queryParams: nil, failBlock: {
        error in
            println(error)
        }, completeBlock: {
        response in
            println(response)
    })

I can get other SOQL queries to work within my iOS app and the user can log in just fine, I think I might be a little off in regards to calling my Apex webservice.

Any suggestions/comments are greatly appreciated! Thanks!


Solution

  • The solution ended up being

    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) })
    

    the endpoint defaults to a string that isn't what you want, so you have to set it to nothing manually in order to get the right results.