How to POST content as application/x-www-form-urlencoded2019 Community Moderator ElectionHow do I POST urlencoded form data with $http without jQuery?How to make POST requests with the FormData APIHow to get JSON back from HTTP POST Request (to another domain)How can I post data as form data instead of a request payload?How do I POST urlencoded form data with $http without jQuery?AngularJS $http.put not working in Firefox or Chrome. Works ok in IESyntaxError: Unexpected token # while displaying text fileHow to set header to the $http.post method AngularJS 1.3.5?Set content-type header to json for request.postAccessing API with $http POST Content-Type application/x-www-form-urlencodedHow to use AngularJS $http to send multipart/form-dataHow to generate a swagger file for the header “Content-Type: application/x-www-form-urlencoded” in Informatica cloud?

Is there a logarithm base for which the logarithm becomes an identity function?

If sound is a longitudinal wave, why can we hear it if our ears aren't aligned with the propagation direction?

Why aren't there more Gauls like Obelix?

Professor forcing me to attend a conference, I can't afford even with 50% funding

When an outsider describes family relationships, which point of view are they using?

The preposition for the verb (avenge) - avenge sb/sth (on OR from) sb

Why do phishing e-mails use faked e-mail addresses instead of the real one?

If nine coins are tossed, what is the probability that the number of heads is even?

Idiom for feeling after taking risk and someone else being rewarded

Use Mercury as quenching liquid for swords?

(Codewars) Linked Lists-Sorted Insert

How do we create new idioms and use them in a novel?

Having the player face themselves after the mid-game

Are all players supposed to be able to see each others' character sheets?

Is divide-by-zero a security vulnerability?

Create chunks from an array

How do you make a gun that shoots melee weapons and/or swords?

Logistic regression BIC: what's the right N?

What is better: yes / no radio, or simple checkbox?

Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?

Trocar background-image com delay via jQuery

Under what conditions can the right to be silence be revoked in the USA?

Short scifi story where reproductive organs are converted to produce "materials", pregnant protagonist is "found fit" to be a mother

What does the Digital Threat scope actually do?



How to POST content as application/x-www-form-urlencoded



2019 Community Moderator ElectionHow do I POST urlencoded form data with $http without jQuery?How to make POST requests with the FormData APIHow to get JSON back from HTTP POST Request (to another domain)How can I post data as form data instead of a request payload?How do I POST urlencoded form data with $http without jQuery?AngularJS $http.put not working in Firefox or Chrome. Works ok in IESyntaxError: Unexpected token # while displaying text fileHow to set header to the $http.post method AngularJS 1.3.5?Set content-type header to json for request.postAccessing API with $http POST Content-Type application/x-www-form-urlencodedHow to use AngularJS $http to send multipart/form-dataHow to generate a swagger file for the header “Content-Type: application/x-www-form-urlencoded” in Informatica cloud?










2















angularjs $http.post is refusing to use my Content-Type



I am working with a contractor - their team are making server-side APIs while I'm putting together a javascript application using angularjs. They insist on making the api only allow calls with application/x-www-form-urlencoded calls, so I'm trying to figure out how to use $http to make a urlencoded call, and running into problems. All the instruction pages I'm finding seem focused on older versions of angularjs.



I try using the below code:



$scope.makeApiCall = function( )
var apiData =
"key1" : "value1",
"key2" : "value2"
;
var apiConfig =
"headers" :
"Content-Type" : "application/x-www-form-urlencoded;charset=utf-8;"

;
return $http.post('/Plugins/apiCall', apiData, apiConfig)
.then(function(response)
$scope.data=response.data;
);
;


But when I make the call, instead of using the Content-Type I provided, the developer tools report that it uses Content-Type: text/html; charset=utf-8



How do I get my $http.post to send the right Content-Type?










share|improve this question




























    2















    angularjs $http.post is refusing to use my Content-Type



    I am working with a contractor - their team are making server-side APIs while I'm putting together a javascript application using angularjs. They insist on making the api only allow calls with application/x-www-form-urlencoded calls, so I'm trying to figure out how to use $http to make a urlencoded call, and running into problems. All the instruction pages I'm finding seem focused on older versions of angularjs.



    I try using the below code:



    $scope.makeApiCall = function( )
    var apiData =
    "key1" : "value1",
    "key2" : "value2"
    ;
    var apiConfig =
    "headers" :
    "Content-Type" : "application/x-www-form-urlencoded;charset=utf-8;"

    ;
    return $http.post('/Plugins/apiCall', apiData, apiConfig)
    .then(function(response)
    $scope.data=response.data;
    );
    ;


    But when I make the call, instead of using the Content-Type I provided, the developer tools report that it uses Content-Type: text/html; charset=utf-8



    How do I get my $http.post to send the right Content-Type?










    share|improve this question


























      2












      2








      2








      angularjs $http.post is refusing to use my Content-Type



      I am working with a contractor - their team are making server-side APIs while I'm putting together a javascript application using angularjs. They insist on making the api only allow calls with application/x-www-form-urlencoded calls, so I'm trying to figure out how to use $http to make a urlencoded call, and running into problems. All the instruction pages I'm finding seem focused on older versions of angularjs.



      I try using the below code:



      $scope.makeApiCall = function( )
      var apiData =
      "key1" : "value1",
      "key2" : "value2"
      ;
      var apiConfig =
      "headers" :
      "Content-Type" : "application/x-www-form-urlencoded;charset=utf-8;"

      ;
      return $http.post('/Plugins/apiCall', apiData, apiConfig)
      .then(function(response)
      $scope.data=response.data;
      );
      ;


      But when I make the call, instead of using the Content-Type I provided, the developer tools report that it uses Content-Type: text/html; charset=utf-8



      How do I get my $http.post to send the right Content-Type?










      share|improve this question
















      angularjs $http.post is refusing to use my Content-Type



      I am working with a contractor - their team are making server-side APIs while I'm putting together a javascript application using angularjs. They insist on making the api only allow calls with application/x-www-form-urlencoded calls, so I'm trying to figure out how to use $http to make a urlencoded call, and running into problems. All the instruction pages I'm finding seem focused on older versions of angularjs.



      I try using the below code:



      $scope.makeApiCall = function( )
      var apiData =
      "key1" : "value1",
      "key2" : "value2"
      ;
      var apiConfig =
      "headers" :
      "Content-Type" : "application/x-www-form-urlencoded;charset=utf-8;"

      ;
      return $http.post('/Plugins/apiCall', apiData, apiConfig)
      .then(function(response)
      $scope.data=response.data;
      );
      ;


      But when I make the call, instead of using the Content-Type I provided, the developer tools report that it uses Content-Type: text/html; charset=utf-8



      How do I get my $http.post to send the right Content-Type?







      angularjs api angularjs-http






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      georgeawg

      33.9k105170




      33.9k105170










      asked Mar 6 at 21:24









      Wolfman JoeWolfman Joe

      6741720




      6741720






















          1 Answer
          1






          active

          oldest

          votes


















          3














          How to POST content as application/x-www-form-urlencoded



          Use the $httpParamSerializerJQLike service to transform the data:



          .controller(function($http, $httpParamSerializerJQLike) 
          //...

          $http(
          url: myUrl,
          method: 'POST',
          data: $httpParamSerializerJQLike(myData),
          headers:
          'Content-Type': 'application/x-www-form-urlencoded'

          );

          );


          For more information, see



          • AngularJS $httpParamSerializerJQLike Service API Reference

          • Stackoverflow -- URL-encoding variables using only AngularJS services





          share|improve this answer

























          • That does the trick, thank you. I was hunting for something like that for hours.

            – Wolfman Joe
            Mar 6 at 22:40










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55032377%2fhow-to-post-content-as-application-x-www-form-urlencoded%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          How to POST content as application/x-www-form-urlencoded



          Use the $httpParamSerializerJQLike service to transform the data:



          .controller(function($http, $httpParamSerializerJQLike) 
          //...

          $http(
          url: myUrl,
          method: 'POST',
          data: $httpParamSerializerJQLike(myData),
          headers:
          'Content-Type': 'application/x-www-form-urlencoded'

          );

          );


          For more information, see



          • AngularJS $httpParamSerializerJQLike Service API Reference

          • Stackoverflow -- URL-encoding variables using only AngularJS services





          share|improve this answer

























          • That does the trick, thank you. I was hunting for something like that for hours.

            – Wolfman Joe
            Mar 6 at 22:40















          3














          How to POST content as application/x-www-form-urlencoded



          Use the $httpParamSerializerJQLike service to transform the data:



          .controller(function($http, $httpParamSerializerJQLike) 
          //...

          $http(
          url: myUrl,
          method: 'POST',
          data: $httpParamSerializerJQLike(myData),
          headers:
          'Content-Type': 'application/x-www-form-urlencoded'

          );

          );


          For more information, see



          • AngularJS $httpParamSerializerJQLike Service API Reference

          • Stackoverflow -- URL-encoding variables using only AngularJS services





          share|improve this answer

























          • That does the trick, thank you. I was hunting for something like that for hours.

            – Wolfman Joe
            Mar 6 at 22:40













          3












          3








          3







          How to POST content as application/x-www-form-urlencoded



          Use the $httpParamSerializerJQLike service to transform the data:



          .controller(function($http, $httpParamSerializerJQLike) 
          //...

          $http(
          url: myUrl,
          method: 'POST',
          data: $httpParamSerializerJQLike(myData),
          headers:
          'Content-Type': 'application/x-www-form-urlencoded'

          );

          );


          For more information, see



          • AngularJS $httpParamSerializerJQLike Service API Reference

          • Stackoverflow -- URL-encoding variables using only AngularJS services





          share|improve this answer















          How to POST content as application/x-www-form-urlencoded



          Use the $httpParamSerializerJQLike service to transform the data:



          .controller(function($http, $httpParamSerializerJQLike) 
          //...

          $http(
          url: myUrl,
          method: 'POST',
          data: $httpParamSerializerJQLike(myData),
          headers:
          'Content-Type': 'application/x-www-form-urlencoded'

          );

          );


          For more information, see



          • AngularJS $httpParamSerializerJQLike Service API Reference

          • Stackoverflow -- URL-encoding variables using only AngularJS services






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday

























          answered Mar 6 at 22:35









          georgeawggeorgeawg

          33.9k105170




          33.9k105170












          • That does the trick, thank you. I was hunting for something like that for hours.

            – Wolfman Joe
            Mar 6 at 22:40

















          • That does the trick, thank you. I was hunting for something like that for hours.

            – Wolfman Joe
            Mar 6 at 22:40
















          That does the trick, thank you. I was hunting for something like that for hours.

          – Wolfman Joe
          Mar 6 at 22:40





          That does the trick, thank you. I was hunting for something like that for hours.

          – Wolfman Joe
          Mar 6 at 22:40



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55032377%2fhow-to-post-content-as-application-x-www-form-urlencoded%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229