Rest API Examples



  • Hey guys,

    Sorry for asking such a simple and generic question but I am fairly new to REST. Right now I am trying using a custom page plugin which will allow me to insert scripts or basic html or php.

    I am trying to learn how to use the API but I am just stumped. I've tried to follow other REST api's online but it seems like this is so simple I'm over thinking this.

    I'm just trying to do something simple like see who the logged in user is and maybe load their profile picture.

    Any guidance would be super helpful. Any links to things I can read to help me understand would be great too.

    Thanks again for taking the time to read this.

    Patrick


  • Global Moderator

    @patnyc so like where are you trying to use this information? Are you trying to interface from another site? Are you trying to add some functionality to NodeBB itself?



  • Hi @PitaJ , thanks for replying!

    Basically, I am creating a custom form that submits to a google sheet. Right now I am using a Google Form with an iFrame to add it to my nodebb site.

    I fear that the users of my site (who are usually ranging from kids to adults) may spam the form to bother admins. (We are a gaming community).

    I just want to pre-populate the first field with the username of the account logged in so we can track form submissions better. The form would be added as a custom page and I would use a HTML widget to add the form.


  • Global Moderator

    @patnyc hmmmm. I think you may be able to use prefilled forms.

    You can go to Get pre-filled link and fill in the username field with [testing], then hit submit. You will be given a link that points to a predefined form with the [testing] username. Then, you can replace [testing] in the link with {user.userslug}. You can then use that link as the source for your iframe.

    Here's an example link:

    Test form

    May or may not work. Okay didn't work in this post. You get the idea though.



  • @PitaJ, yeah i just tested it out.... It didnt seem to work (on the google form) but would this technically work if I made a form field hidden and prefilled that text box with that?

    I want to avoid using the google form.


  • Global Moderator

    @patnyc did you try it in an iframe element in an HTML widget? That might work.

    I'm not sure about custom forms writing to Google docs, but you could definitely use one with a hidden input holding {user.userslug} if that's possible.



  • @PitaJ

    I did, the result returned a black field.

    I already have a custom form that submits to a google sheet im working on so if i can use {user.userslug} for a hidden field called username then im set?


  • Global Moderator

    @patnyc yeah that should work.


Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.