QWIK api returns 500 error

Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank.

Builder content link

Builder public api key
dc5c96804c6c4a068e9558f30660aaee

Detailed steps to reproduce the bug
Use the Qwik API to retrieve the content of the contact page
https://cdn.builder.io/api/v1/qwik/product-landing-page?apiKey=dc5c96804c6c4a068e9558f30660aaee&url=/contact

Screenshots or video link

Code stack you are integrating Builder with
NextJS 13 (addDir)

Hi @vperrin,

Please publish the content for contact, and then for the URL use userAttribute.urlPath=/contact

This seems to work for us
https://cdn.builder.io/api/v1/qwik/product-landing-page?apiKey=dc5c96804c6c4a068e9558f30660aaee&includeUnpublished=true

I also tried another content with /search, which also seems to work

https://cdn.builder.io/api/v1/qwik/product-landing-page?apiKey=dc5c96804c6c4a068e9558f30660aaee&userAttribute.urlPath=/search&includeUnpublished=true

Hi @manish-sharma ,

Thanks for getting back to me quickly.

I published the page and followed your recommendation to use the parameter userAttribute.urlPath.
The API still returns a 500 error though, see link below.

https://cdn.builder.io/api/v1/qwik/product-landing-page?apiKey=dc5c96804c6c4a068e9558f30660aaee&userAttribute.urlPath=/contact

Thanks,
Vincent

Hi @vperrin,

This looks like an issue only with the contact page query, I tried removing all builder content from the contact page and was able to query the contact page.

https://cdn.builder.io/api/v1/qwik/product-landing-page?apiKey=dc5c96804c6c4a068e9558f30660aaee&userAttribute.urlPath=/contact&includeUnpublished=true

Hi @manish-sharma ,

So what is the solution to get the API working with the existing content?
I’ve had a 500 error in the past, see QWIK api returns error for content

Thanks,
Vincent

Hi @vperrin,

We can query other existing content, except the contact page, we are investigating this further, and we will update you as soon as we have any insights. Thank you!

1 Like

HI @vperrin,

Here is what we see on our end:

If you navigate to:

But if you go to:

  • Builder.io: Drag & Drop Headless CMS You will see that it is found to state.hits[0].url The issue is that state.hits is not defined because results[0].data.state did not have hits .

As a result of the above, the page fails to render.

Yes, we need to do a better job on error msg, but we think the fix may be as simple as adding state.hits[0]?.url ?

Hi @manish-sharma ,

Thanks for getting back to me.

Initially, I used the parameter &url=/contact, after which you suggested using &userAttribute.urlPath=/contact.
But I just noticed a typo in that. Looking at the docs, the correct parameter should be &userAttributes.urlPath=/contact.

With the typo, the API call goes to our home page / and not the /contact page. The homepage is expected not to work using the qwik API because we pass information to the SDK as a data prop.

But without the typo, the API call for the /contact page still fails, see below.
https://cdn.builder.io/api/v1/qwik/product-landing-page?apiKey=dc5c96804c6c4a068e9558f30660aaee&userAttributes.urlPath=/contact

Please let me know if this is not clear.
Thanks,
Vincent

Hi @vperrin,

Have you tried the proposed solution of setting state.hits[0]?.url ?

Hi @manish-sharma ,

The solution you proposed is for a different page. The /contact page doesn’t use the state object. By having a typo in your query parameter you ended up on a different page. Please use the url from my previous email.

Thanks,
Vincent

Hi @vperrin,

Thanks for the clarification, we are looking into this.

Hi @vperrin,

This looks to be an issue with the builder form component, which is causing Qwik API to fail. if you remove the form component and then try the below query you will see the response.

https://cdn.builder.io/api/v1/qwik/product-landing-page?apiKey=dc5c96804c6c4a068e9558f30660aaee&userAttributes.urlPath=/contact

Hi @manish-sharma ,

Thanks for getting back to me.
Is this a misconfiguration of the form component or a bug in the qwik API? If it is a bug, are there plans to fix it?

Thanks,
Vincent

Hi @vperrin,

This could be a possible bug with Qwik SDK, I’ve escalated the issue for further investigation and a fix. I’ll update you as soon as we have insights from our product team.

Meanwhile, as a workaround, you can create a custom form instead of using the builder form component. Thank you!

Hi @manish-sharma ,

Thanks for confirming it’s a bug.
I’ll look at alternatives.

Thanks,
Vincent

1 Like