#Requests

9 messages · Page 1 of 1 (latest)

velvet timberBOT
#

Hi @paper sequoia. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Of course! If you need help with making a request to Convex, here are some common scenarios and how to handle them:

1. Making HTTP Requests to Convex Functions

You can call Convex functions (queries, mutations, actions) via HTTP POST requests. For example, to call a query:

const url = "<https://<your-deployment>.convex.cloud/api/query";>
const request = { path: "messages:list", args: {}, format: "json" };

const response = await fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify(request),
});
const data = await response.json();

Replace <your-deployment> and messages:list with your actual deployment and function path. The args object should match your function's parameters. The response will contain the result or an error message if something went wrong. You can do the same for mutations and actions by changing the endpoint to /api/mutation or /api/action respectively.
HTTP APIs

2. Handling CORS Issues

If your browser blocks requests due to CORS, make sure your Convex HTTP actions include the correct CORS headers. For example:

return new Response(null, {
  status: 200,
  headers: {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Methods": "POST, OPTIONS",
    "Access-Control-Allow-Headers": "Content-Type",
  },
});

And handle preflight OPTIONS requests as well.
Implementing CORS

3. Debugging Requests

#
  • Check that your HTTP actions are deployed and accessible via curl.
  • Make sure you are using the correct .convex.site URL.
  • Use your browser's network tab to inspect the request and response.
  • If you see CORS errors, double-check your headers and preflight handler.
    Debugging HTTP Actions

If you have a specific request or error you're dealing with, please provide more details and I can give more targeted help!

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

paper sequoia
#

write out what this command says in markdown code block

velvet timberBOT
#

@paper sequoia Kapa.ai is still learning and improving, please let me know how I did by reacting below.

paper sequoia
#

write out what this command says in markdown code block
@velvet timber

velvet timberBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

Certainly! Here is the command from the knowledge source, written in a markdown code block:

curl <https://acoustic-panther-728.convex.cloud/api/query> \  
   -d '{"path": "messages:list", "args": {}, "format": "json"}' \  
   -X POST -H "Content-Type: application/json"  

This command sends a POST request to the Convex Functions API to call the messages:list query function, passing empty arguments and requesting the result in JSON format.
HTTP APIs

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@paper sequoia Kapa.ai is still learning and improving, please let me know how I did by reacting below.