Exception: Param: msa_name - Text filter requires a scalar value.

Options
Hello,

I am trying to use the api to post some data from an external service I use into a table but keep getting the error "Exception: Param: limit_type - Text filter requires a scalar value.".

I tried looking this error up in the documentation and community, but have not found anything. Even when googling it I mostly get examples for matlab which do not help me understand any better. Please advise on how to fix this.

I have no programming experience so I will try and explain as best I can the scenario. I am trying to set up an api endpoint to POST data from an external webscrape service. Everything seems to work up to when I try to add records to the table at which point I get the error. The data I am receiving is a json file that looks a bit like the following:
[screenshot.PNG]
I have atempted modifying the table fields, the webscrape and the api a number of different times but no matter what I always seem to get this error. Any advice would be appreciated.

Thank you

Comments

  • Christopher J Tholberg
    Options
    UPDATE. I figured out what the issue was but instead of deleting the post I though I would share my stupidity in case someone else finds it helpful in the future. 

    Long story short, I needed to loop through the results. In the above scenario the json file was returning 50 records. I was trying to add all of them to the table as one record. So to correct this I created a for loop and as soon as I did that it ran perfectly without issue and added the records to the table. 

    Hope this helps someone. 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Glad you sorted it out, and thank you for sharing the solution 🙂
  • Ruark
    Ruark Member
    Options
    Hey there. Im experiencing the same issue trying to replicate the "External APIs: Adding multiple records from an external API" tutorial video (https://www.youtube.com/watch?v=rdnuW2Vg8aA)

    I am using a for each loop, but getting the same error? [Screenshot 2022-04-27 132738.png]
    {"code":"ERROR_CODE_INPUT_ERROR","message":"Text filter requires a scalar value.","param":"name"}
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     are you using the item variable within your add record? is the value you are trying to add actually text or is it an array? one of these will likely solve your question...

    Keep in mind, you can use the debugger see where your function stack hit the error and see the values being passed
  • Seno
    Seno Member
    Options
      having the same problem here. capital is a list now (according to REST Countries), but in the video it is not. what should I write in the red-circled field in order not to get the error?
    thanks[image.png]
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    You probably want to update you database schema to a list if there can be multiple capitals per country. If your use case doesn't care for that and you just want whichever comes first, then I would apply the first filter to the path
  • Gi Ma
    Gi Ma Member
    Options

    Hi there,

    I'm experiencing a similar error, in the following setting:

    • one table includes a foreign key, but this column is set up as "single"
    • yet I get the "requires a scalar value" error when trying to pass this foreign key (id) on to another function
    • this other function also uses "single" as a structure
    • so what I have to do as a workaround is use the filter "first" before passing this foreign key to the other function, to get the first array. this way, it works. however it makes no sense to have to use this, since the structure is set to "single", or am I misunderstanding something here?

    Again, the workaround works, but I don't think it makes sense to proceed like this

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hi @Gi Ma - it sounds like you are dealing with an array of one value. So even if it is only a single value, an array is an array. You can determine this by examining the output of the other function if it has the flat brackets [] that surround the value.

  • Gi Ma
    Gi Ma Member
    Options

    Thank you @Michael Udinski for getting back to me! Indeed, it is an array, which is why working with "First" filter solves the trick. However, I don't understand why this specific column, which contains a foreign key (unique ID from other table), and knowing the row's structure is set to "Single", is returning an array? is that wanted behavior or a bug?

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    @Gi Ma - can you provide some more details on the function and its settings? Screenshots would be super helpful!

  • cojarbi
    cojarbi Member
    Options

    Hi, im having the same issue. i was trying to replicate the process with my own data but kept getting empty records on save. So i went ahead and used your same example. Regardless of what i do either get empty records or get this error which means either meaning i must be providing the path wrong or is the worng data.


    Here is a sample of what the json data looks like before being passed to the loop


    If i try to only get population by using the json item i get essage: Unable to locate var: item.0.population

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hey @cojarbi - I'd recommend removing the index from your dot notation. You want to use the index only if you want to get the exact position of an array. Since you are doing a for each loop, your var: item because a single item from the array. So var: item.population should be what you want

  • cojarbi
    cojarbi Member
    Options

    @Michael Udinski thanks that worked great. One question. Im only getting 50 records total, is this a limitation?

  • pacifist9722
    Options

    @Michael Udinski having the error problem:

    Error: Text filter requires a scalar value

    Param: currencies & language


    What I noticed was that in the video tutorial you're using v2 of the restcountries API, in which languages & currencies are an array. (Screenshot 1)

    In the recent version (v3), it's not an array( [] is missing) , they simply put it as a list of objects. (Screenshot 2)

    What kind of field type in the database could handle such data? I tried array, objects and simple text.


  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    hi @cojarbi it sounds like your external API is returning 50 records, maybe there is pagination -- there wouldn't be a limit from Xano

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    @pacifist9722 looks like they've changed quite a bit since the creation of the tutorial. It looks like the fields in the object are going to have dynamic keys, which is doable in a object but you'd have to account for all variability. It would make the most sense to use a JSON data type that can handle flexible structures.

  • pacifist9722
    Options

    @Michael Udinski thank you. Objects worked for languages. JSON data type worked great for currencies as they have dynamic keys.

  • benmccarthy
    benmccarthy Member
    Options

    I had the same error. "Exception: Param: field_value - Text filter requires a scalar value."

    This was my output from a 'query all records' function. It returned the id value of the one record I was trying to match:
    matchedLike: [
    {
    id: 11
    }
    ]

    I initially put it into a 'Delete record' function like:
    field_name = id
    field_value = matchedLike.id

    And that function returned the error above. What was happening was that it expected just one value, but I gave it a list that had one value (you can tell because it's within square brackets []). Fix:
    field_value = matchedLike.0.id

    In other words, just grab the first value of the list.

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    @benmccarthy - if you are always expecting one value from your Query All Records, you can also change your return type from list to single. (Query All Records>Output>Return). This will return your result as a single object instead of an array, then you won't need to include the index in your dot notation.