0

I've stuck with a problem I didn't imagine could happen. I need to make a post request for the third-party API which allows only this

let parameters: Parameters = [{
        "id": "1",
        "original-address": "Some city, Some street"}]

As you can see it is not a dictionary, so compiler says Cannot convert value of type '[() -> String]' to specified type 'Parameters' (aka 'Dictionary<String, Any>')

I could not remove the brackets because my 3rd party API will not respond to this request.

How can I send such a request with Alamofire?

I've tried some suggestions from our beloved Stackoverflow, but still no luck.

pulp
  • 1,768
  • 2
  • 16
  • 24
  • `Alamofire is arguing` what do you even mean by this? Did you try removing the brackets? – EmilioPelaez Nov 30 '18 at 20:42
  • @EmilioPelaez I mean compiler throws the error with description `Cannot convert value of type '[() -> String]' to specified type 'Parameters' (aka 'Dictionary')` I could not remove the brackets because my 3rd party API will not respond to this request. – pulp Nov 30 '18 at 20:50

1 Answers1

0

Parameters is a typealias for [String:Any] and you assign

[{
    "id": "1",
    "original-address": "Some city, Some street"}]

which looks like json array of dictionaries ( Not even swift array of Dics ) , so you can't pass it to Alamofire , to accomplish what you need send it in the request body as Data look to Sending json array via Alamofire

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87