# Testing via Curl and getting No records detected in request error 400

**URL:** <https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309>\
**Category:** REST API\
**Created:** [September 2, 2014, 12:42pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309 "2014-09-02T12:42:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickgaurd](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nickgaurd](https://community.dreamfactory.com/u/nickgaurd)\
**Post date:** [September 2, 2014, 12:42pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/1 "2014-09-02T12:42:09Z")

</div>

Im testing the following curl statement in order to POST into a particular table:

curl -H “X-DreamFactory-Application-Name: UAT” -X POST [http://localhost/rest/UAT/CRM\_LEAD](http://localhost/rest/UAT/CRM_LEAD)  
-d ‘{“STEP\_CODE”:“ENQ”,“DOC\_GUID”:“10000”,“DOC\_DATE”:“2014-07-24”,“DOC\_REF”:“WEB\_SUBMISSION”,“ORIGINATOR”:“ADMIN”}’

but every time that I try it I get back the error “No record(s) detected in request”.

Any ideas?  
I’d also like to just use the REST API without having to specify the Application, since all I want to be able to do is POST some data into one of the services that I have created. Is that possible?

---

<div class="post-metadata">

**Author:** ![Mark](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mark/32/69_2.png) [@Mark](https://community.dreamfactory.com/u/Mark)\
**Post date:** [September 2, 2014, 4:34pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/2 "2014-09-02T16:34:26Z")

</div>

Have a look at this cURL PATCH request - and see if you can PATCH a record simply for testing purposes:

**Update** todo with id = 1 -----\> be sure to append the 1 to cURL

```
curl -k -3 -X PATCH https://dsp-yourdsp.cloud.dreamfactory.com/rest/db/todo/1 \
  -H "X-DreamFactory-Application-Name: app_name here" \
  -H "X-DreamFactory-Session-Token: session token here" \
  -d '{ "name" : "success"}'

```

If you notice the rest/db( **service** )/todo( **table** )/1( **record** )

So, this will clearly update record one’s complete **name** field to: **success**

note: change the values to match what’s in your todo DB, but only try to update one value.

* * *

POSTing a record doesn’t require any id params, as it should update the id (most likely the primary key) by one.

curl -k -3 -X POST [https://dsp-yourdsp.cloud.dreamfactory.com/rest/db/todo](https://dsp-yourdsp.cloud.dreamfactory.com/rest/db/todo)   
-H “X-DreamFactory-Application-Name: app name here”   
-H “X-DreamFactory-Session-Token: token here”   
-d ‘{ “name” : “curl todo”, “complete” : false }’

* * *

As far as your question about updating the db without having an actual app\_name in the request. You can preview how to do this with your Live API - simple go to the db service, and create records using valid JSON and it’ll become clear very quick how it’s done.

You’ve probably seen this but if not, have a look:

[https://github.com/dreamfactorysoftware/dsp-core/wiki/Common-Headers-Parameters](https://github.com/dreamfactorysoftware/dsp-core/wiki/Common-Headers-Parameters)

[https://github.com/dreamfactorysoftware/dsp-core/wiki/cURL-Examples](https://github.com/dreamfactorysoftware/dsp-core/wiki/cURL-Examples)

Let me know if you’ve got anymore questions.

Thanks,

- Mark

---

<div class="post-metadata">

**Author:** ![nickgaurd](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nickgaurd](https://community.dreamfactory.com/u/nickgaurd)\
**Post date:** [September 15, 2014, 8:54pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/3 "2014-09-15T20:54:12Z")

</div>

Hi Mark,

I have been trying to get this to work, but I just cant seem to get any record to PATCH or to POST.

I cant figure out how to get a successful GET even.

What settings do I need to make in an application in order to connect it to a Service?

---

<div class="post-metadata">

**Author:** ![nickgaurd](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nickgaurd](https://community.dreamfactory.com/u/nickgaurd)\
**Post date:** [September 15, 2014, 8:56pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/4 "2014-09-15T20:56:37Z")

</div>

Or am I wrong? I dont need a service to access a db from a REST URL and I am approaching this in the wrong fashion?

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [September 15, 2014, 9:18pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/5 "2014-09-15T21:18:42Z")

</div>

Hey Nick, what database are you trying to access? You need to have a service set up in DreamFactory to call it with REST. There’s a default service called /db which is provided for you in the DSP and returns data from the default MySQL database. Or you can add your own database as a service.

See these [cURL examples](https://github.com/dreamfactorysoftware/dsp-core/wiki/cURL-Examples) for the todo table in /db. There are some [screencast examples](https://www.youtube.com/playlist?list=PL2nQn3mpqAp6GKFAab0HROrZXZHeXMdPh) too which demonstrate API calls with cURL. Remember to pass in an app ID and session token to the API call, like below (get the session token from a login POST to /user/session). As a DSP admin you will automatically have access to the /db service. If you set up other roles, you need to grant /db API access to the role (CRUD permissions).

```
curl -k -3 -X GET https://dsp-yourdsp.cloud.dreamfactory.com/rest/db/todo \
  -H "X-DreamFactory-Application-Name: todojquery" \
  -H "X-DreamFactory-Session-Token: bhc7lov8r41h4cbn6pue1r63gbgh7jf6"

```

---

<div class="post-metadata">

**Author:** ![nickgaurd](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nickgaurd](https://community.dreamfactory.com/u/nickgaurd)\
**Post date:** [September 16, 2014, 9:01am UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/6 "2014-09-16T09:01:06Z")

</div>

Hi Ben,

Let me just run through this,

I’ve set-up a service called UAT which connects to a SQL Database (The Swagger API works nicely). In this DB there is a table called CRM\_LEAD that I wish to see if I can POST entries into from a web service.

I’ve enabled CORS with a \* value for the moment, and I have enabled Guest User with the Role UAT-ROLE which is enabled for CRUD operations on the service UAT. So I shouldnt need a session ID from what I understand.

With regard to the App ID, I havent really built an app as all I want to experiment with is the REST service directly. Could you recommend how I should set-up the App so that I can simply write files into this DB?

Thank you

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [September 16, 2014, 3:55pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/7 "2014-09-16T15:55:05Z")

</div>

Got it. So you do need to pass app name, but it’s trivial to set up. In the Apps tab of the DSP admin console, just create a new app and use the name of the app as the app ID (i.e. API key) in your REST calls. Note that the REST service you created does not need to know anything about this app…apps and services are completely decoupled.

There’s more info on API key [here](https://github.com/dreamfactorysoftware/dsp-core/wiki/Important-Information). If you’re still having issues, you might want to email [support@dreamfactory.com](mailto:support@dreamfactory.com) so we can help get your calls sorted out.

---

<div class="post-metadata">

**Author:** ![nickgaurd](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nickgaurd](https://community.dreamfactory.com/u/nickgaurd)\
**Post date:** [September 16, 2014, 6:43pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/8 "2014-09-16T18:43:57Z")

</div>

Hi Ben,

Ok, I’ve tried that now, but I am getting another error stating “No record(s) detected in request.”

Ill email through to support though, Im using the following curl request.

curl -k -3 -X POST [http://LOCALHOST/rest/UAT/CRM\_LEAD](http://LOCALHOST/rest/UAT/CRM_LEAD) -H “X-DreamFactory-Application-Name: UAT\_APP” -d ‘{“PROCESS\_CODE”:“PROPERTYSALES”,“STEP\_CODE”:“ENQ”,“DOC\_GUID”:“10000”,“DOC\_DATE”:“2014-07-24”,“DOC\_REF”:“WEB\_SUBMISSION”,“ORIGINATOR”:“ADMIN”,“LEAD\_STATUS”:“A”,“LEAD\_CURRENCY”:“£”,“SALUTATION”:“Mr”,“L\_NAME”:“cunhatest10”,“F\_NAME”:“hugotest10”,“COUNTRY\_CODE”:“UK”,“EMAIL”:“hugo.cunha10@jellyfish.co.uk”,“GENERAL\_INTEREST”:"",“SOURCE\_CODE”:“TOBEQUALIFIED”,“COMPLETION\_STATUS”:“D”,“APPROVAL\_STATUS”:“N”,“TEL\_3”:“345345111”,“CNT\_MEHOD\_CODE”:“INTERNET-ENQUIRY”,“DECLINE\_USE”:“Y”}’

---

<div class="post-metadata">

**Author:** ![Mark](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mark/32/69_2.png) [@Mark](https://community.dreamfactory.com/u/Mark)\
**Post date:** [September 16, 2014, 8:29pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/9 "2014-09-16T20:29:14Z")

</div>

Nick,

First, open browser and turn on debugger. Go to your live api on the admin console, scroll through the services and open the sql server (which would be UAT from your curl request) - and perform a GET. Basic, top-level, GET.

What was the response and the request URL (within swagger, the live api).

Now… perform a POST against your MSSQL server using the exact data that you’re trying to POST via cURL - which will accomplish the same thing, but that’s not the reason I’m asking you to do it.

After you do this, look at the request URL and let me know what it is, via forum or respond to the email I just replied to. Now, go into the debugger and look for the REQUEST and RESPONSE information… In chrome or firefox (think u need firebug installed for FF).

But, yeah it should be as simple as what you already have.

```
curl -k -3 -X POST http://localhost/rest/UAT/CRM_LEAD \
  -H "X-DreamFactory-Application-Name: UAT_APP" \
  -d '{ "name" : "game", "complete" : false }'

```

Thanks,

Mark

---

<div class="post-metadata">

**Author:** ![nickgaurd](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nickgaurd](https://community.dreamfactory.com/u/nickgaurd)\
**Post date:** [September 17, 2014, 6:34am UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/10 "2014-09-17T06:34:06Z")

</div>

Hi Mark,

The response from the top level get was a response body that listed all of the tables and then all of the permissions applicable.

The request URL was:

[http://localhost:80/rest/UAT](http://localhost:80/rest/UAT)

When I then POST to CRM\_LEAD using the Swagger API it takes ages to perform the action (a good few minutes) and then came back with **no content** to the URL  
[http://localhost:80/rest/UAT/CRM\_LEAD](http://localhost:80/rest/UAT/CRM_LEAD)

I ran it a second time to be sure and then within a few seconds it had returned with a correct

{  
“DOC\_GUID”: “10000”  
}

and now I can see my data in the back-end.

Ill see if I can find the REQUEST RESPONSE information

Nick

---

<div class="post-metadata">

**Author:** ![Mark](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mark/32/69_2.png) [@Mark](https://community.dreamfactory.com/u/Mark)\
**Post date:** [September 17, 2014, 1:54pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/11 "2014-09-17T13:54:01Z")

</div>

So, it is working for you now, there’s now a performance issue?

No worries on the request/response if all is good for you - continue to run a few tests to see if performance is still giving you difficulty and we’ll go from there.

Thanks,

- Mark

---

<div class="post-metadata">

**Author:** ![nickgaurd](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nickgaurd](https://community.dreamfactory.com/u/nickgaurd)\
**Post date:** [September 17, 2014, 3:04pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/12 "2014-09-17T15:04:27Z")

</div>

I can get it to work from swagger, but I cant get it work from curl, which is what I really need to demonstrate. The same data is used and everything that I can think of but I get an error where it seems to think that the data sections are tables it should be looking up.

I cant find the request/response in the debug information either as Im not too familiar with the tool. Im using Chrome but I may take a look at Firebug.

---

<div class="post-metadata">

**Author:** ![Mark](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mark/32/69_2.png) [@Mark](https://community.dreamfactory.com/u/Mark)\
**Post date:** [September 17, 2014, 3:18pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/13 "2014-09-17T15:18:35Z")

</div>

Which OS are you using again? I think it is Windows… In which case, some users I’ve noticed have to use double quotes and escape characters for -d value. It is worth a shot at this point, I’d say.

[This image is no longer available]

Try the one that has **28** next to it - this should address your issue.

Give that a try and if doesn’t work then take a look at [this on StackOverflow](http://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest), as it has a few other potential solutions.

Thanks,

- Mark

---

<div class="post-metadata">

**Author:** ![nickgaurd](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nickgaurd](https://community.dreamfactory.com/u/nickgaurd)\
**Post date:** [September 22, 2014, 12:59pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/15 "2014-09-22T12:59:04Z")

</div>

Right, this seems to be the solution here:

[http://stackoverflow.com/questions/11834238/curl-post-command-line-on-windows-restful-service](http://stackoverflow.com/questions/11834238/curl-post-command-line-on-windows-restful-service)

Effectively, under windows command line, cURL messes up the JSON formatting. I tested now using the Advanced Rest Client tool and also with curl under cygwin and it works properly. Apologies for the confusion but its a good one to note for others.

Thank you for all your help.

N

---

<div class="post-metadata">

**Author:** ![Mark](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mark/32/69_2.png) [@Mark](https://community.dreamfactory.com/u/Mark)\
**Post date:** [September 22, 2014, 3:22pm UTC](https://community.dreamfactory.com/t/testing-via-curl-and-getting-no-records-detected-in-request-error-400/309/16 "2014-09-22T15:22:57Z")

</div>

Great man! Awesome work.

Thanks,

- Mark
