mike4aday / SwiftlySalesforce

The Swift-est way to build native mobile apps that connect to Salesforce.
MIT License
135 stars 43 forks source link

When I include a “+” in the url query parameter in the salesforce.apex mothod, it seems to be replaced by a space on the server. #58

Closed hmuronaka closed 6 years ago

hmuronaka commented 6 years ago

When I include a “+” in the url query parameter in the salesforce.apex(:method:.get, path,path, queryParameters:) mothod, it seems to be replaced by a space on the server.

When SwiftlySalesforce was in version Alamofire, I could use the “+” character was replaced with the correct value of “%2B” without any problems. Now it is replaced with ” “.

What is the correct way to build my query parameter that includes the “+” character?

https://stackoverflow.com/questions/43052657/encode-using-urlcomponents-in-swift

mike4aday commented 6 years ago

Thanks @hmuronaka, I'll look into this. To help me reproduce, can you post the code you are using to build the URL.

hmuronaka commented 6 years ago

Please try below queryParameters for reproduce.


salesforce.apex(method: .get, path:path, queryParameters:["date": "2018-01-18T00:55:32.000+0000"])
`

Please refer my pullrequest #59 for update.
mike4aday commented 6 years ago

Thanks @hmuronaka - resolved with version 6.0.3

mike4aday commented 6 years ago

@hmuronaka FYI you can use the DateFormatter extension in Swiftly Salesforce to format dates for Salesforce:

    public static let salesforceDateTimeFormatter: DateFormatter = {
        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
        return formatter
    }()
hmuronaka commented 6 years ago

["date": "2018-01-18T00:55:32.000+0000"] is one of example. I think escaping is necessary also in cases like ["keyword": "abc + def"] and so on...

Anyway thank you your information and for merging my pullrequest!

mike4aday commented 6 years ago

@hmuronaka indeed. I just meant you could, instead of writing out the date as a string, use: DateFormatter.salesforceDateTimeFormatter.string(from: myDateValue)

Thank you for the pull request.