[Solved] Sending Boolean = True, getting "invalid" wont accept "1"

Options
Hi guys,

I am sending an API request Parameter as follows:

isGlobal: 
true,
isRollupReportingLocation:
false,

And Im getting the following returned:

400 Error
location.IsGlobal: [The value '1' is not valid for IsGlobal.],
location.IsRollupReportingLocation: [The value '0' is not valid for IsRollupReportingLocation.]

Anyone had this issue before? I can't see where this is sending as a "1" rather than "true". Is there a way to see the raw data to see if Xano is converting my "true" to "1"? 

Comments

  • Sam Bevis
    Sam Bevis Member
    Options
    [image.png]Fixed it by forcing a string... however for debugging purposes it would be great to understand how I could see the RAW data being sent (showing the boolean being sent as a "1" rather than "true"
  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
     is for an API request you are sending out? If so, sending your request to something like https://webhook.site instead of the external service  URL would let you see the exact payload you are transmitting. 
  • Sam Bevis
    Sam Bevis Member
    Options
     yes it was for posting a new entry via an API - but I was getting an error with the boolean.
    Thanks for another debugging option - it's a shame you cant view the raw request within Xano itself (unless its hidden somewhere?).
    When I get into the nitty of my next build Ill sign up to your statechange membership so I can hassle you over there 😃
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     You can use your API Request History to view the payload that is being sent - open a request and expand the input... You can even copy the input with the click of a button and paste it in your debugger to run with the exact payload that was sent. Regarding booleans, Xano stores and sends out booleans as true/false - it wouldn't transform these values when being sent or outputted. But Xano ACCEPTS boolean values of true/false, yes/no, and 1/0 
  • Sam Bevis
    Sam Bevis Member
    Options
     I was developing in the Library>Functions area - so I didnt have access to the API>Request history. As a workaround Im guessing I could set it to a task, then view the task history?

    If Xano doesnt convert a "true" to "1" I wonder why I was getting that error response? I was definatley sending a "boolean true" with my request in the function stack, and then getting the error as a response. It was only when I forced the "text" into the request when it started to work... anyway its all working now :) Cheers mate.
  • Sam Bevis
    Sam Bevis Member
    Options
      - it would also be super handy if we could post "code snippets" in this community help area, to make it easier to read 🙂
  • Jacksonm93
    Jacksonm93 Member
    Options

    How did you solve it, Your image not visible!

  • bok
    bok Member
    edited July 2023
    Options

    how did you fix it i have the same issue while creating a csv i don't get true just 1 and empty if false

  • Sam Bevis
    Sam Bevis Member
    edited July 2023
    Options

    Hi @bok @Jacksonm93 - as per my first reply in this post, I had to force a "String" stating the words "true" and it worked. When it was set to boolean it was sending a "1" instead of the words "true".

  • bok
    bok Member
    Options

    how did you force a string? replace is not working for me

  • Sam Bevis
    Sam Bevis Member
    Options
  • Sam Bevis
    Sam Bevis Member
    Options

    @bok - did that fix it for you?

  • pachocastillosr
    pachocastillosr Member
    edited September 2023
    Options

    This bug is still happening to me as of Sept 21, 2023.

    When saving a boolean into a json object in Xano's database you must convert the boolean it into a text value, otherwise, when retrieving it from the database, you will get a number instead of the boolean.

  • pachocastillosr
    Options

    Might be worth looking into it @Michael Udinski