Skip to content
Back

True is not a valid boolean??????!!!?!?

  • 0
  • React Native
  • Cloud
SorryLad2
24 Nov, 2024, 00:40

Please someone. I am dying. how is true not a valid boolean here???

(NOBRIDGE) ERROR Error calling Appwrite function: [AppwriteException: Invalid async param: Value must be a valid boolean]

const response = await functions.createExecution( "FUNCTION_ID", JSON.stringify({ images: processedImages }), { async: true }, { headers: { 'Content-Type': 'application/json' } } );

TL;DR
Developers were struggling with understanding how to handle Boolean values in their Appwrite function. The issue stemmed from passing `async=true` instead of `{ async: true }`. The correct syntax for passing a Boolean value as a parameter was shown as `{ async: true }` in the `functions.createExecution` method.
Steven
24 Nov, 2024, 00:42

Can you try passing just true instead of an object?

SorryLad2
24 Nov, 2024, 00:44

const response = await functions.createExecution( "FUNCTION_ID", JSON.stringify({ images: processedImages }), async=true, { headers: { 'Content-Type': 'application/json' } } );

SorryLad2
24 Nov, 2024, 00:44

like that?

Steven
24 Nov, 2024, 00:44

No, just true

Steven
24 Nov, 2024, 00:44

Like how you passed just the function id

SorryLad2
24 Nov, 2024, 00:48

that stopped that error but now I think it thinks the headers is the path param

Steven
24 Nov, 2024, 00:49

Because it is 😜 order matters.

SorryLad2
24 Nov, 2024, 00:49

Do you have to fill out all the params if you want to specify the content-type? The whole reason I am doing this is because it isn't recognizing my json and just sending as plain-text I think

SorryLad2
24 Nov, 2024, 00:50

then on my back end, when I try to get the req.payload it is undefined

Steven
24 Nov, 2024, 00:50

req.payload doesn't exist 🧐

SorryLad2
24 Nov, 2024, 00:51

Are there examples of this? I don't even know what I would put for the other params

@param xpath

@param method

SorryLad2
24 Nov, 2024, 00:51

and yeah when I try to log it, it is just undefined. I have been stumped for hours@

SorryLad2
24 Nov, 2024, 00:51

!

Steven
24 Nov, 2024, 00:52

Because it's never defined. That doesn't exist. Don't know where you saw that it does exist

Steven
24 Nov, 2024, 00:53
SorryLad2
24 Nov, 2024, 00:55

omg wait haha so req.payload isn't even a thing??? I should be doing req.bodyJson

SorryLad2
24 Nov, 2024, 00:57

was trying to do this in my function

module.exports = async function (req, context) { try { console.log("Function execution started."); console.log("Received payload:", req.payload);

TypeScript
// Parse and log the payload
let images;
try {
  const parsedPayload = req.payload ? JSON.parse(req.payload) : {};
  images = parsedPayload.images || []; // Default to empty array if images is missing
  console.log("Parsed payload successfully:", parsedPayload);
} catch (parseError) {
  console.log("Failed to parse payload:", req.payload, parseError);
  return context.res.json({
    error: "Invalid payload. Ensure it is valid JSON with an 'images' array."
  });
}
Steven
24 Nov, 2024, 00:58

If you're passing application/json for the Content-Type header. Otherwise, use bodyText and convert using JSON.parse()

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more