I’ve an app that should call this API:
http://109.168.113.11/Acucgi/G7TestWeb.sh?funzione=charge_pms&utente=WXWX&password=TESTWWW1&azienda=RISTORANTE&modo=Json&fl_ad=A&camera=5&data_del=20231004&codadd[0]=V10&qtaadd[0]=1&impadd[0]=7,80&desadd[0]=Cappuccinos
In my app I’ve developed a class who can call this API, but from iOS 17 I’ve several problem because Apple has updated to RFC 3986 the url encoding.
Here’s my code:
let urlString = "http://109.168.113.11/Acucgi/G7TestWeb.sh?funzione=charge_pms&utente=WXWX&password=TESTWWW1&azienda=RISTORANTE&modo=Json&fl_ad=A&camera=5&data_del=20231004&codadd[0]=V10&qtaadd[0]=1&impadd[0]=7,80&desadd[0]=Cappuccinos"
guard let url = URL(string: urlString) else {
print("!! url !!")
return
}
var request = URLRequest(url: sysDatUrl)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
[MANAGE RESPONSE]
}
By using this code the server answer me an error because my app use the following url:
http://109.168.113.11/Acucgi/G7TestWeb.sh?funzione=charge_pms&utente=WXWX&password=TESTWWW1&azienda=RISTORANTE&modo=Json&fl_ad=A&camera=5&data_del=20231004&codadd%5B0%5D=V10&qtaadd%5B0%5D=1&impadd%5B0%5D=7,80&desadd%5B0%5D=Cappuccinos
As you can see in my url iOS changed the character [
with %5B
and ]
with %5D
. To work with my server I must use the [
and ]
, if I use the %5B
and %5D
my integration will not work anymore. There’s a way to keep the character [
and ]
?
Thank you
The issue is server side – characters like
[
and]
are not allowed URL characters, so the ate percent-encoded. Your server should expect to receive those characters percent encoded. If anything, it’s weird that prior to iOS 17 the URL initializer returned valid URL instance when passed a string without those characters percent encodedIf this is really your server don’t misuse the URL query to pass hard-coded index subscription syntax. A better syntax could be to pass the index separately
…data_del=20231004&codadd=V10&qtaadd=1&impadd=7,80&desadd=Cappuccinos&addIndex=0