Hii guys i post json to my endpoint backend that don’t work
but tha’s work fine with postman POST ? PLZ help me
Hii guys i post json to my endpoint backend that don’t work
but tha’s work fine with postman POST ? PLZ help me
Your server request seems wrong. Check the ID spellings and number of ID’s too. Check in RESTClient whether it is working or not
the GET request work fine in chrome but POST is not working, also with postman the same post work on but on chrome is not working
there is my post function
doPostJSON(url: string, jsondata: any) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let options = new RequestOptions({ headers: headers, method: "post" });
console.log("url to post: ", url, "\n json to post: ", jsondata);
return this.http.post(url, jsondata, options)
}
here is endpoint function in php
// sign_up user
public function signup() {
header(‘Access-Control-Allow-Origin: *’);
//header(‘Access-Control-Allow-Headers: X-Requested-With’);
header(“Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept”);
header(‘Access-Control-Allow-Methods: POST, GET, OPTIONS’);
$this->load->model('users_mobile_model');
$input_data = json_decode(trim(file_get_contents('php://input')), true);
$data = array(
'numCarte' => $input_data['num_Carte'],
'nom' => $input_data['nom'],
'prenom' => $input_data['prenom'],
'email' => $input_data['email'],
'id_type' => $input_data['id_type_abonnement'],
'password' => $input_data['password'],
);
$last_id = $this->users_mobile_model->add_user($data);
if($last_id)
$this->res_display(200, 'OK');
}
u means my client request not my server that’s it ?
Is your jsondata that you send correct?
You can try to send the server error back to the client to see what is going wrong.
You are in a mobile environment where CORS applies. (Google it if you don’t know about it yet).
Your server has to respond to an OPTIONS request additionally to the POST you want to do.
Okey i solved the isssue, by allowing OPTIONS method in .htacces.
thk u so much