Error when using smart-compose API

Hello,
I’m using the Node.js SDK, specifically the composeMessageReply method. When I call this method, I get an HTTP 400 error with the message: *“Something went wrong. Please try again later.”*

I double-checked the parameters passed to composeMessageReply and also looked into the SDK source code in node_modules. The request to the API seems correct:

/v3/grants/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/messages/xxxxxxxxxxxxxxxx/smart-compose.

Additionally, in the logs (inside my dashboard), I couldn’t find any requests related to smart-compose — they simply don’t show up there.

Could you please advise what might be causing this issue?

Hello!

The response should contain a Request Id could you provide that to us?

Thank you!

it’s gone :frowning:

error in your code nylas-nodejs/src/apiClient.ts at cd026427d0b9146aa7da807c46c499ee33efd8df · nylas/nylas-nodejs · GitHub

setRequestHeaders({ headers, overrides, }) {
    const mergedHeaders = {
        ...headers,
        ...this.headers,
        ...overrides?.headers,
    };

Looks like there is an error in your code base here. I tried to change it in this way and after that got request id in the response

setRequestHeaders({ headers, overrides, }) {
    const mergedHeaders = {
        ...headers,
        ...this.headers,
        ...(overrides?.headers ? overrides.headers : {})
    };

after that, I got this

{ "request_id" : "9ac42e825010454990688be1955785da", "error" : { "type" : "unexpected_error", "message" : "Something went wrong. Please try again later." } }.

"request_id" : "9ac42e825010454990688be1955785da"

curl --request POST --url ‘https://api.us.nylas.com/v3/grants/0f819490-5b3d-4e66-b647-3a1a2da0634e/messages/199536d4bbf3e064/smart-compose’ --header ‘Accept: application/json, application/gzip’ --header ‘Authorization: Bearer *******’ --header ‘Content-Type: application/json’ --data ‘{“prompt”: “Reply to John Doe about the upcoming project.”}’ {“request_id”:“ca5a75769caa489cb1d0fd5ff379a6c1”,“error”:{“type”:“unexpected_error”,“message”:“Something went wrong. Please try again later.”}}

and

curl --request POST --url ‘https://api.us.nylas.com/v3/grants/0f819490-5b3d-4e66-b647-3a1a2da0634e/messages/smart
-compose’ --header ‘Accept: application/json, application/gzip’ --header ‘Authorization: Bearer ******’ --header ‘Content-Type: application/json’ --data ‘{“promp
t”: “write to John Doe about new random project.”}’
{“request_id”:“840e47019dee4a4c8835db8a366615ea”,“error”:{“type”:“unexpected_error”,“message”:“Something went wro
ng. Please try again later.”}}

using Curl, I get a similar result.

Hello @odmin4eg ,

I took a look at your account and did not find any error messages related similar to your example, were you able to resolve the issue?

If not, could you provide a fresh example / request_id? I’d be happy to look into it further for you.