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
2
Answers
The string that your server requires is not a valid URL, which means that your server implements a protocol that is similar to HTTP, but is not actually HTTP. Apple’s frameworks only support certain protocols, and do not support this non-standard protocol that your server implements. There is no way to express an invalid URL as an
URL
.The best solution is to correct your server so that it decodes HTTP messages properly. That includes handling percent-encoded URIs.
If cannot or do not wish to modify your server, then you’ll need to implement this custom protocol by hand. Since this is very close to HTTP, that’s pretty easy.
This is the kind of code you’d write. I haven’t tested it much, but it should hopefully get you one the right path:
Same issued, but it is working in iOS 16 and under. Any other solution?