Need Help ! Post data to RESTful service

I am fairly new to web service. I made a RESTful web service and integrated it to my web server.
Here is my web service API

public function service_get()
      $data['services'] = $this->m_klien->getServiceList(); 
public function vehicle_get()
    $data['get_vec'] = $this->m_vehicle->get_all();

public function order_post()
	$data = array
        'order_date' => $this->post('order_date'),
        'start' => $this->post('start'),
        'end' => $this->post('end'),
        'plate_num' => $this->post('plate_num'),
        'vehicle_type' => $this->post('vehicle_type'),
        'order_type' => $this->post('order_type'),
        'id_clients' => $this->post('id_clients'),
        'id_mechanic' => $this->post('id_mechanic'),
        'payment_deadline' => $this->post('payment_deadline'),
		'payment_amount' => $this->post('payment_amount'),
		'status' => $this->post('status')
    $this->m_klien->setOrder($data, null);

Now i want to use the post method to save data to my server. Here is what i’ve been doing :
I followed the instruction here
my service :

.factory('Post', function($resource) {
         return $resource('');

on my controller :

$scope.dummy = {
	    order_date :'2015-09-25 09:00:00',
            start :'2015-09-27 09:00:00',
            end :'2015-09-27 09:30:00',
            plate_num :'AB1234XYZ',
            vehicle_type : '7',
            order_type : 'mobile',
            id_clients : '1',
            id_mechanic : '1',
            payment_deadline : '2015-09-25 13:00:00',
	    payment_amount: '500000',
            status : '1'
$scope.postData = function() {
	var post = new Post($scope.dummy);

The problem is the data doesn’t seem to be saved on my database. I’ve tested my API using Wiztools RESTclient and it worked just fine so i know that the problem is on the client side.

Maybe it’s just in this message but there’s a missing paren in your postData definition, it should be:

$scope.postData = function() {
	var post = new Post($scope.dummy);

Then maybe the problem is in the way you call postData().

sorry it’s just a typo when i copied the code. There are no any errors when i run the program

OK but how do you call postData? So far you showed only how you defined it.

I just call it from a button like

<button class="button button-block button-assertive" ng-click="postData()">

Are you sure your API expects data sent in JSON and not in x-www-form-urlencoded?

I tried to encode my json to x-www-form-urlencoded but still not working

$scope.jsonToURI = function(json)
	return encodeURIComponent(JSON.stringify(json)); 

$scope.postData = function() {
     var post = new Post($scope.jsonToURI($scope.dataTobesent));

my new service

.factory('Post', function($resource) {
	 return $resource('',{},{
	 query: {
		 headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}


it returns no error in console.
However when i tried to use $http it returns failed

        $scope.dummy = encodeURIComponent($scope.dummy); 
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
		url: '',
		method: "POST",
		data: $scope.dummy 
	.then(function(response) {
		//return succes
	function(response) { // optional
		//return failed

Did you print the response when it fails?

Yes, and this makes me confused

Object { data: "<!DOCTYPE html> <html lang="en"> <h…", status: 500, headers: headersGetter/<(), config: Object, statusText: "Internal Server Error" }

when i test it with WizTools RESTclient, the data is saved in the DB and the response is

HTTP/1.1 201 Created

That RESTclient tool uses “application/x-www-form-urlencoded; charset=UTF-8”

For an error 500, the only way to understand what is going on is to look at the server logs hoping that the error has been logged with more details. If you wrote the server it’s even easier.