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 8739961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:02:52+00:00 2026-06-13T11:02:52+00:00

When I make a post request using the following curl -i -d username=rock&password=rock http://my_VM_IP/api/1.1/json/my_login/

  • 0

When I make a post request using the following

curl -i -d "username=rock&password=rock" http://my_VM_IP/api/1.1/json/my_login/

it generates the required response generating a token like this(abridged):

HTTP/1.1 200 OK
Date: Mon, 22 Oct 2012 08:37:39 GMT
Vary: Authorization,Accept-Language,Cookie,Accept-Encoding
Content-Type: text/plain
Transfer-Encoding: chunked
OK{"success": {"my_token": "required_token"}}

But when I try the same including a header as:

curl -i -H "Content-Type:application/json" -d "username=rock&password=rock" http://my_VM_IP/api/1.1/json/my_login/ 

it gives me the following error:

HTTP/1.1 400 BAD REQUEST
Date: Mon, 22 Oct 2012 11:12:04 GMT
Vary: Authorization,Accept-Language,Cookie,Accept-Encoding
***Content-Type: text/plain***
Content-Language: en-us
Connection: close
Transfer-Encoding: chunked
Bad Request

I dont understand why this happens. And also why does the content-Type show text/plain, I also tried looking at some other questions like Why Setting POST Content-type:"Application/Json" causes a "Bad Request" on REST WebService? . It also addresses the same problem I have. Following the answer in that I tried giving the data in various formats as

{"username":"rock", "password":"rock"} 

but without success. 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-13T11:02:52+00:00Added an answer on June 13, 2026 at 11:02 am

    By using -H "Content-Type:application/json" you’re setting the Content-Type header for your request. The response will still return whatever your view tells it to return.

    To return a response with Content-Type application/json, use something along these lines:

    import json
    from django.http import HttpResponse
    
    def json_response(return_vars):
        'JSON-encodes return_vars returns it in an HttpResponse with a JSON mimetype'
        return HttpResponse(json.dumps(return_vars), content_type = "application/json")
    
    #Usage: return json_response({'admin_token': admin_api_token.token})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I make a POST request using the following code: string body = Hello
I would like to make POST request using following code <div class=editor-field id=updateDiv >
I am using the following function to make a post request: bool NewAccountDialog::verifyAccount() {
I'm using clojure-http to make the following POST: (clojure-http.resourcefully/post https://android.apis.google.com/c2dm/send {Authorization (str GoogleLogin auth=
I wanted to make a post request in this website: http://www.prezup.info/index.php?page=films in order to
I want to make a HTTP Post request from C#. This request has a
Am using a script to make a simple post request to my Django backend.
I want to make http form post using NSURLConnection in iOS. I have two
I am using following code to make a ajax request. But how to configure
i am trying to make the post using my linkedin api application, The issue

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.