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

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page