Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9035455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:45:47+00:00 2026-06-16T08:45:47+00:00

Hi every one, I have a login form which has mail id and password,

  • 0

Hi every one,
I have a login form which has mail id and password, on submit it should call an api which inturn generates a auth token. I have used POST method in Php curl but getting the following error.

Apache Tomcat/6.0.36 – Error report
.. some html styles..
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method

and this is my ajax call..

function callapi()
{ 
data = new Object();
var email= document.getElementById("input01").value;
var pwd=document.getElementById("input02").value;
if(email != ""&& pwd != "")
{
data.Email = email;
data.Pwd = pwd;

}

jQuery.ajax({ 
  url: "http://localhost/stackato/nlogin.php",
  type: "POST",
  dataType:"json",
  data:data,
  error: function (data) {
   alert('error--'+data);
  },
  success: function (data) { 

if(data=="invalid")
{

}
else
{

window.location.href="finalstackatolists1.html";
}



}
});

}

and this is my curl php page

<?php
header('Content-type: application/json');
$url = $_SERVER['REQUEST_URI'];
$scriptname = $_SERVER['SCRIPT_NAME']; 
$queryString = $_SERVER['QUERY_STRING'];
$mail=$_POST["Email"];
$pwd=$_POST["Pwd"];
$action = $_POST["action"];


$nurl = str_replace($scriptname,"...the api...",$url);




//open connection

$ch = curl_init(); 
$data = array("username" => $mail, "password" => $pwd);                                                                    
$req_data = json_encode($data);  

curl_setopt($ch, CURLOPT_URL, $nurl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req_data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);


 //execute post

if( ! $result = curl_exec($ch)) {
    die(curl_error($ch));
    curl_close($ch);
}

if(curl_getinfo($ch, CURLINFO_HTTP_CODE) == '500')
{
    header("Status: 500 Server Error");
}

curl_close($ch);


echo $result;


?>

(I tried it in REST-Client and the token has been generating)

Please help me to solve this.. thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:45:48+00:00Added an answer on June 16, 2026 at 8:45 am

    You have to specify that the posted data is of type JSON

    add this line to your curl code

    curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which has one field username . If some one submit
i have one setinterval method which call php script every 3 sec to check
Hi every one I have these classe @Entity @Table(name = login, uniqueConstraints={@UniqueConstraint(columnNames={username_fk})}) public class
Hello every one I have wrote a simple code in html5 in which I
Hai every one I am developing an windows application in which i have to
I am writing my own blog (every one should, it's good experience). I have
I have a set of services in my web service. every one should be
I have to run a bit of code in the background every one second,
I have a windows service that does some intensive work every one minute (actually
I have a directory full of JPEGs. I want to convert every one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.