PricingDocsAcademy
Bluesky ...
Fri, Dec 13, 9:11 AM

API POST error

  • /attachments/1300511444932235275/1300513152500240435/Screenshot_2024-10-28_at_18.32.09.png

    MachtigeMaxim

    1 month ago

    Hey, so im making a web app and I need to pull data from a POST request.

    I get an error 500 on that request telling me (AttributeError: 'str' object has no attribute 'get')

    It is caused (I think) because the backend receives the JSON message sent via the POST request as a string instead of a JSON object.

    This is the body payload:
    {"question": "Wat is het wereldnieuws van vandaag?"}

    When I do a cURL api request in Postman everything works fine. What could it be?
    Screenshot_2024-10-28_at_18.32.09.png
    Screenshot_2024-10-28_at_18.34.24.png
  • Lucas G

    1 month ago

    That is a string, yeah
  • Build it as an object if you need to be JSON
  • MachtigeMaxim

    1 month ago

    Lol. Thanks. Changed that in the main script. Couldn’t understand why Postman would give it a , but toddle doesn’t. I still don’t know tho, but it works.
  • Lucas G

    1 month ago

    It’s just a matter of data types.
    toddle doesn’t automatically make it into a JSON
  • You choose the type of data you want to send
  • Lucas G

    1 month ago

    If you want to pass in a string then you can use a formula node to encode it
  • MachtigeMaxim

    1 month ago

    Ah ok thanks! Did that.

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.