REST API with variable in the URL

Hello,
I’m trying to check if Flotiq can get integrated using Rest API and it doesn’t look good right now :smiley:
I don’t know if their API design is good but to get a blog post we need to use the URL:
https://api.flotiq.com/api/v1/content/flotiqBlogPost/blogPostId

A correct API design would have been https://api.flotiq.com/api/v1/content/flotiqBlogPost/?id=blogPostId in my opinion but that’s not the case.

So my question is: Is there a way to send a variable as part of the URL (endpoint)?

Thank you

Hi @bktag

Yes, it’s possible :slight_smile:

Inside Request settings, scroll down and find properties, add the new property let’s call it “id” and set default value.

Then in endpoint, do something like this

https://api.flotiq.com/api/v1/content/flotiqBlogPost/${properties->get(‘id’)}

This should be enough, now you can create single-page inside builder

  1. Create new page or use existing
  2. Set the source to the request you’ve created
  3. Set route to include /:id (this is must, because the property you created is id)

We are working on improving variable system. The REST API doesn’t have yet variable popup which would make things easier.

Hi Dejan,

Thank you for your clear answer!
Will have a look and try it :slight_smile:
The only problem as I see is that the URL will have the ID. It might work but it will look ugly as the IDs are “flotiqblogpost-12345567889”.
Will check if I can change that in Flotiq.

Too bad their API doesn’t fetch by slug…

Thank you again for your answer :slight_smile:

@bktag

Yeah, that’s not ideal. Slug would be much better.
Let me know if you need any help, I can help also with some of setup.

1 Like

I just had a try and it doesn’t seem to work.
The property is always null even if I put a default value.
image

And same in the page, the source is giving 404 result.

This is my settings:


@bktag

Could you share your domain name so I can check what’s going on?

@bktag

It should be this ${properties->get('id')} instead of ${properties->get(‘id’)}

So the difference is only → ' instead of → ’

I don’t know what I did as it’s always looking like an arrow for me. But it worked in the end :slight_smile:
Thank you!

@bktag

The single quotes should not be curved :smiley:

1 Like