Call of overloaded is ambiguous

I have a int (numberid), which adds one to itself every cycle. Next, I have a JSONArray (ids) that contains int numbers. And I want that after each cycle I have a request to a site whose subdomain is equal to some number from the array:

client.begin("http://mysitename/" + String(ids[numberid]) + "/");

However, when trying to do this, an error occurs:

call of overloaded 'basic_string(ArduinoJson6194_F1::ElementProxy<ArduinoJson6194_F1::ArrayRef>)' is ambiguous

What am I doing wrong? When trying to do this just by the number of the array element:

client.begin("http://mysitename/" + String(numberid) + "/");

no errors occur

Post ALL your code.

all 550 lines of terrible code? :smiley:

Yes. It really is very hard for anyone to try and find issues with just part of the code. If your car wouldn't start you wouldn't just bring the carburettor to the mechanic because you thought that's where the problem was?

I think the problem is just the syntax. The compiler works with a number, but does not want to work with the number of an array element

Hard to say without the code. For example I have no idea what type of variable numberID or ids are?

But if it helps, here's part of the code. First we make a request using the main link:

int numberid = 1;
HTTPClient client;
    client.begin("http://mysitename/");   
    int httpCode = client.GET();                                     
    if (httpCode > 0) {
      char json[700];
      getids.toCharArray(json, 700);
      Serial.println(json);
      StaticJsonDocument <700> doc;                                    
      DeserializationError err = deserializeJson(doc, json);          

then we save the parsing values in jsonarray:

JsonArray ids = doc["id"];
arraysize = ids.size();
client.end();

then performing some function and adding one to numberid (int):


...
numberid++;

then again the request by link, but to the ling we add the value of the array element corresponding to numberid


HTTPClient client;
client.begin("http://mysitename/" + String(ids[numberid]) + "/");

I have asked for the code 3 times already! ... this is the 4th and last time.

1 Like

Rather than the whole thing, a complete but shorter piece of code that compiles and illustrates the problem would be better.

(post deleted by author)

I understood. First we write it to JSONArray:

JsonArray ids = doc["id"];

Then we find the size of the array:

arraysize = ids.size();

And then we just cyclically write all the values to another array:

for (int i = 0; i < arraysize; i++) {
  int ids2[i] = {ids[i]};                                    
}

After that, we turn to the site by the number (which is the counter) of the array element:

client.begin("http://mysitename/" + String(ids2[numberid]) + "/");

And it works fine!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.