MSGraph-SDK-Code-Generator icon indicating copy to clipboard operation
MSGraph-SDK-Code-Generator copied to clipboard

EntityRequest.cs.tt - duplicate check for AdditionalData response headers

Open MIchaelMainer opened this issue 6 years ago • 0 comments

We are generating duplicate checks for response headers and status codes for PATCH scenarios.

        public async System.Threading.Tasks.Task<User> UpdateAsync(User userToUpdate, CancellationToken cancellationToken)
        {
			if (userToUpdate.AdditionalData != null)
			{
				if (userToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
					userToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
				{
					throw new ClientException(
						new Error
						{
							Code = GeneratedErrorConstants.Codes.NotAllowed,
							Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, userToUpdate.GetType().Name)
						});
				}
			}
            if (userToUpdate.AdditionalData != null)
            {
                if (userToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    userToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                        new Error
                        {
                            Code = GeneratedErrorConstants.Codes.NotAllowed,
                            Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, userToUpdate.GetType().Name)
                        });
                }
            }
            this.ContentType = "application/json";
            this.Method = "PATCH";
            var updatedEntity = await this.SendAsync<User>(userToUpdate, cancellationToken).ConfigureAwait(false);
            this.InitializeCollectionProperties(updatedEntity);
            return updatedEntity;
        }

AB#7106

MIchaelMainer avatar Aug 21 '19 00:08 MIchaelMainer