Angular 7 HttpClient put request params sending null values to endpointAngular - Set headers for every requestAngular HTTP GET with TypeScript error http.get(…).map is not a function in [null]Angular HttpClient doesn't send headerHow do I set the baseUrl for Angular HttpClient?Catching errors in Angular HttpClientusing the request method in Angular's HttpClient classAngular HttpClient returns null value for response of zeropass params in angular get httpclient requestAsp.Net Core FromBody parameter always null on angular PUT requestAngular HttpClient use URL Params in POST

How to find better food in airports

To which country did MiGs in Top Gun belong?

What is the maximal acceptable delay between pilot's input and flight control surface actuation?

Why is k-means used for non normally distributed data?

Would there be balance issues if I allowed opportunity attacks against any creature, not just hostile ones?

Why do modes sound so different, although they are basically the same as a mode of another scale?

Calculus Books, preferably Soviet.

Initializing a std::array with a constant value

slowest crash on the Moon?

Is there anything in the universe that cannot be compressed?

How is total raw calculated for Science Pack 2?

Why did the VIC-II and SID use 6 µm technology in the era of 3 µm and 1.5 µm?

Why are Latin and Sanskrit called dead languages?

Design of 50 ohms RF trace for 2.4GHz...Double layer FR-4 PCB

How did Gollum know Sauron was gathering the Haradrim to make war?

Map a function that takes arguments in different levels of a list

Why don't they build airplanes from 3D printer plastic?

What happens if you just start drawing from the Deck of Many Things without declaring any number of cards?

Lumix G7: Raw photos only in 1920x1440, no higher res available

Received email from ISP saying one of my devices has malware

Why do many programmers abstain from using global variables?

Declaring 2 (or even multi-) dimensional std::arrays elegantly

Why does this syntax outputs an error under METAFUN/METAPOST?

What is this red bug infesting some trees in southern Germany?



Angular 7 HttpClient put request params sending null values to endpoint


Angular - Set headers for every requestAngular HTTP GET with TypeScript error http.get(…).map is not a function in [null]Angular HttpClient doesn't send headerHow do I set the baseUrl for Angular HttpClient?Catching errors in Angular HttpClientusing the request method in Angular's HttpClient classAngular HttpClient returns null value for response of zeropass params in angular get httpclient requestAsp.Net Core FromBody parameter always null on angular PUT requestAngular HttpClient use URL Params in POST






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have an Angular service with this Put request method:



put(peopleFieldID: number, peopleFieldName: string): Observable<number> 
let params = new HttpParams();
params = params.append("peopleFieldID", peopleFieldID.toString());
params = params.append("peopleFieldName", peopleFieldName);

return this.http
.put<number>(this.url, params: params )
.pipe(catchError(this._errorHandling.handleError.bind(this)));


The above hits this endpoint on my .net core API:



 [Authorize(Roles = "Client")]
[Route("")]
[HttpPut]
public IActionResult C_Update(int peopleFieldID, string peopleFieldName )

//Make call to the proper repo method.
return Json(_peopleFieldRepo.C_Update(peopleFieldID, peopleFieldName));



The two params, peopleFieldID and peopleFieldName, are always 0 and null. I have pinpointed that the Angular frontend sends the params correctly, but the backend cannot recognize them. I have many other endpoints where this works just fine.










share|improve this question






























    1















    I have an Angular service with this Put request method:



    put(peopleFieldID: number, peopleFieldName: string): Observable<number> 
    let params = new HttpParams();
    params = params.append("peopleFieldID", peopleFieldID.toString());
    params = params.append("peopleFieldName", peopleFieldName);

    return this.http
    .put<number>(this.url, params: params )
    .pipe(catchError(this._errorHandling.handleError.bind(this)));


    The above hits this endpoint on my .net core API:



     [Authorize(Roles = "Client")]
    [Route("")]
    [HttpPut]
    public IActionResult C_Update(int peopleFieldID, string peopleFieldName )

    //Make call to the proper repo method.
    return Json(_peopleFieldRepo.C_Update(peopleFieldID, peopleFieldName));



    The two params, peopleFieldID and peopleFieldName, are always 0 and null. I have pinpointed that the Angular frontend sends the params correctly, but the backend cannot recognize them. I have many other endpoints where this works just fine.










    share|improve this question


























      1












      1








      1








      I have an Angular service with this Put request method:



      put(peopleFieldID: number, peopleFieldName: string): Observable<number> 
      let params = new HttpParams();
      params = params.append("peopleFieldID", peopleFieldID.toString());
      params = params.append("peopleFieldName", peopleFieldName);

      return this.http
      .put<number>(this.url, params: params )
      .pipe(catchError(this._errorHandling.handleError.bind(this)));


      The above hits this endpoint on my .net core API:



       [Authorize(Roles = "Client")]
      [Route("")]
      [HttpPut]
      public IActionResult C_Update(int peopleFieldID, string peopleFieldName )

      //Make call to the proper repo method.
      return Json(_peopleFieldRepo.C_Update(peopleFieldID, peopleFieldName));



      The two params, peopleFieldID and peopleFieldName, are always 0 and null. I have pinpointed that the Angular frontend sends the params correctly, but the backend cannot recognize them. I have many other endpoints where this works just fine.










      share|improve this question














      I have an Angular service with this Put request method:



      put(peopleFieldID: number, peopleFieldName: string): Observable<number> 
      let params = new HttpParams();
      params = params.append("peopleFieldID", peopleFieldID.toString());
      params = params.append("peopleFieldName", peopleFieldName);

      return this.http
      .put<number>(this.url, params: params )
      .pipe(catchError(this._errorHandling.handleError.bind(this)));


      The above hits this endpoint on my .net core API:



       [Authorize(Roles = "Client")]
      [Route("")]
      [HttpPut]
      public IActionResult C_Update(int peopleFieldID, string peopleFieldName )

      //Make call to the proper repo method.
      return Json(_peopleFieldRepo.C_Update(peopleFieldID, peopleFieldName));



      The two params, peopleFieldID and peopleFieldName, are always 0 and null. I have pinpointed that the Angular frontend sends the params correctly, but the backend cannot recognize them. I have many other endpoints where this works just fine.







      angular asp.net-web-api asp.net-core angular-httpclient






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 2:04









      CAlexCAlex

      1891 silver badge10 bronze badges




      1891 silver badge10 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          3















          You need to set query params using HttpParams and pass null for payload if you do not have any:



          const params = new HttpParams()
          .set('peopleFieldID', peopleFieldID.toString())
          .set('peopleFieldName', peopleFieldName);
          // if you have a payload to pass you can do that in place of null below
          return this.http
          .put<number>(this.url, null, params: params )
          .pipe(catchError(this._errorHandling.handleError.bind(this)));}





          share|improve this answer

























          • This did solve the issue. I thought because the body param was optional, that it wouldn't matter if I did not include it. I don't include it on Get requests, but it makes sense why I would need it on Post/Puts. Thank you!

            – CAlex
            Mar 28 at 2:47






          • 1





            Yeah, you don't need the body for Get but Put and POST need it , so send null if you don't have any need.

            – nircraft
            Mar 28 at 13:15










          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%2f55389128%2fangular-7-httpclient-put-request-params-sending-null-values-to-endpoint%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















          You need to set query params using HttpParams and pass null for payload if you do not have any:



          const params = new HttpParams()
          .set('peopleFieldID', peopleFieldID.toString())
          .set('peopleFieldName', peopleFieldName);
          // if you have a payload to pass you can do that in place of null below
          return this.http
          .put<number>(this.url, null, params: params )
          .pipe(catchError(this._errorHandling.handleError.bind(this)));}





          share|improve this answer

























          • This did solve the issue. I thought because the body param was optional, that it wouldn't matter if I did not include it. I don't include it on Get requests, but it makes sense why I would need it on Post/Puts. Thank you!

            – CAlex
            Mar 28 at 2:47






          • 1





            Yeah, you don't need the body for Get but Put and POST need it , so send null if you don't have any need.

            – nircraft
            Mar 28 at 13:15















          3















          You need to set query params using HttpParams and pass null for payload if you do not have any:



          const params = new HttpParams()
          .set('peopleFieldID', peopleFieldID.toString())
          .set('peopleFieldName', peopleFieldName);
          // if you have a payload to pass you can do that in place of null below
          return this.http
          .put<number>(this.url, null, params: params )
          .pipe(catchError(this._errorHandling.handleError.bind(this)));}





          share|improve this answer

























          • This did solve the issue. I thought because the body param was optional, that it wouldn't matter if I did not include it. I don't include it on Get requests, but it makes sense why I would need it on Post/Puts. Thank you!

            – CAlex
            Mar 28 at 2:47






          • 1





            Yeah, you don't need the body for Get but Put and POST need it , so send null if you don't have any need.

            – nircraft
            Mar 28 at 13:15













          3














          3










          3









          You need to set query params using HttpParams and pass null for payload if you do not have any:



          const params = new HttpParams()
          .set('peopleFieldID', peopleFieldID.toString())
          .set('peopleFieldName', peopleFieldName);
          // if you have a payload to pass you can do that in place of null below
          return this.http
          .put<number>(this.url, null, params: params )
          .pipe(catchError(this._errorHandling.handleError.bind(this)));}





          share|improve this answer













          You need to set query params using HttpParams and pass null for payload if you do not have any:



          const params = new HttpParams()
          .set('peopleFieldID', peopleFieldID.toString())
          .set('peopleFieldName', peopleFieldName);
          // if you have a payload to pass you can do that in place of null below
          return this.http
          .put<number>(this.url, null, params: params )
          .pipe(catchError(this._errorHandling.handleError.bind(this)));}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 28 at 2:25









          nircraftnircraft

          3,6622 gold badges15 silver badges32 bronze badges




          3,6622 gold badges15 silver badges32 bronze badges















          • This did solve the issue. I thought because the body param was optional, that it wouldn't matter if I did not include it. I don't include it on Get requests, but it makes sense why I would need it on Post/Puts. Thank you!

            – CAlex
            Mar 28 at 2:47






          • 1





            Yeah, you don't need the body for Get but Put and POST need it , so send null if you don't have any need.

            – nircraft
            Mar 28 at 13:15

















          • This did solve the issue. I thought because the body param was optional, that it wouldn't matter if I did not include it. I don't include it on Get requests, but it makes sense why I would need it on Post/Puts. Thank you!

            – CAlex
            Mar 28 at 2:47






          • 1





            Yeah, you don't need the body for Get but Put and POST need it , so send null if you don't have any need.

            – nircraft
            Mar 28 at 13:15
















          This did solve the issue. I thought because the body param was optional, that it wouldn't matter if I did not include it. I don't include it on Get requests, but it makes sense why I would need it on Post/Puts. Thank you!

          – CAlex
          Mar 28 at 2:47





          This did solve the issue. I thought because the body param was optional, that it wouldn't matter if I did not include it. I don't include it on Get requests, but it makes sense why I would need it on Post/Puts. Thank you!

          – CAlex
          Mar 28 at 2:47




          1




          1





          Yeah, you don't need the body for Get but Put and POST need it , so send null if you don't have any need.

          – nircraft
          Mar 28 at 13:15





          Yeah, you don't need the body for Get but Put and POST need it , so send null if you don't have any need.

          – nircraft
          Mar 28 at 13:15








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          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%2f55389128%2fangular-7-httpclient-put-request-params-sending-null-values-to-endpoint%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript