Rena Hearn
Posts: 0
Joined: Thu Jul 24, 2014 7:04 am

Queries for dreamfactory rest api

Can some one please help? I have used Dreamfactory to create a rest API for an existing mysql database. I have the services setup and can get a successful test response.

My problem is that I can't seem to find a good tutorial on how to create a query for the data I am trying to get. It seems that the test returns lots of info...none of which is actual database data. I am sure this a query 101 question, but I am a newbie, DIY person....

The tutorials I have found don't really explain for using a rest api like dreamfactory.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Queries for dreamfactory rest api

Hello Rena,

Please look up in this doc http://devcenter.appery.io/documentat...

Rena Hearn
Posts: 0
Joined: Thu Jul 24, 2014 7:04 am

Queries for dreamfactory rest api

Thank You Alena, I have read that. I seems to be geared more toward a database api hosted with appery.

I need specific direction for a remote database api. The remote api tutorials all seem to be for specific 3rd party api. Any other that I am missing?

Mark Stephens
Posts: 0
Joined: Tue Sep 09, 2014 5:51 pm

Queries for dreamfactory rest api

Rena,

I received an email from you and have followed up with you there - just in case you have not received it though I'll give you a bit of info on successful db querying now.

So, you have reached a point where the service (db) has been created and is functional. How were you able to know the response was successful? I assume via the Live API.

If you look at the Live API, as you browse through the various REST verbs, you'll notice the model schema. If you want to specify certain fields within your queries, then you will have to send your JSON request including the "fields" found within the schema.

A good way to sum it up is to go to your API DOCS (the live api) on the left side of your DSP Admin Console. Open this and go through all of your services to see how they work. This is very important as an introduction to the Dreamfactory Service Platform.

Please e-mail me if you have any more questions.

Thank you,

  • Mark
Rena Hearn
Posts: 0
Joined: Thu Jul 24, 2014 7:04 am

Queries for dreamfactory rest api

Hi Mark, Thanks for the email. I will converse on here since others may have the same questions.

I get a successful test when I test the data service through appery when setting up a RestAPI. Through the Chrome api tester I can get data returned, I just cant figure out the right combination to get it through appery.

So when setting up a RESTapi service with appery you have Settings, Request, Response, Test and Echo. I get the successful test here with tons of lines, one of which is the models section. I have setup service settings with my base_url (gotten from the api screen on DF site.) Here are some images. I have tried several different combinations (2days worth). I have tried many things that aren't pictured. I am sure it is just some dumb setting I am not getting right.
Image

Image

Image

Like I said, I am just using DreamFactory as a api for my MySql database.

I am going to be able to get the data from these settings or do I need some additional code to run during the search? If so, can you help me with that?

THANK YOU!

Mark Davies
Posts: 0
Joined: Mon Sep 01, 2014 8:50 am

Queries for dreamfactory rest api

Hi Rena,

Not sure if this would help, but I too spent most of my weekend trying to figure out what is different with my call to DreamFactory when I do it through my RESTClient on Firefox and then when I do it through Appery.io.

What made the difference for me was that in the live api documentation you get a URL like this:
https://dsp-mine.cloud.dreamfactory.c...
but this link gives me a 500 error in Appery. I was also fortunate to get some help from Mark it seems that leaving out the :443 port in the URL gets it to work in Appery.io (do not ask me why... I just know that it works).

My final called looked something like this:
https://dsp-mine.cloud.dreamfactory.c...

This will help you with getting a session, but you have to pass in the email and password as parameters (via the body) to get a successful sign-in.

Once you have done that, you would have a session_id that you should store in local storage and then you can pass that as a header parameter via a parameter called X-DreamFactory-Session-Token (remember to mark this request parameter as a HEADER parameter).

Hope this helps,

Rena Hearn
Posts: 0
Joined: Thu Jul 24, 2014 7:04 am

Queries for dreamfactory rest api

Mark, my response leaves the session id blank. What am I missing? I have a ticket, but no session.

Rena Hearn
Posts: 0
Joined: Thu Jul 24, 2014 7:04 am

Queries for dreamfactory rest api

I GOT IT!!! WOOOHOOOO! IT RETURNS DATA IN THE TEST!

BUT I still can't find the right settings to make it filter....any tips?

Will the session id ever expire? When you said store in local storage and use it, I just pasted it into my request parameters. Is that right?

I am sorry to ask you more questions! You have been a blessing to me today!!

Mark Davies
Posts: 0
Joined: Mon Sep 01, 2014 8:50 am

Queries for dreamfactory rest api

Hi Rena,

Glad that helped you too.

In the test area of the service you will not be able to store it to a local storage variable yet, but you can do that in one of your service calls, probably one of the first things you do in your app is to let the user log in and then during this login service call you will get the data back as you are seeing in the test. You can then create a localStorage variable in the response section of the service and then map the session_id to your localStorage variable. This is then available for the remainder of your session.

In any other subsequent calls you will then be able to map your localStorage variable to the input request parameter X-DreamFactory-Session-Token that is required as a header parameter in all your requests.

Hope that makes sense.

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Queries for dreamfactory rest api

Hi

Can anyone please assist with returning filtered data from a query. I have created a query service but the query parameters has no effect as all the data from the table is returned. It seems like Dreamfactory uses a different method than Appery/Mongo to return data based on a query.

Thx

Return to “Issues”