Skip to content

Upload app logo resulted in Error #745

Open

Description

@ritu-rubrik

Using the below code to upload an Logo for a given App:

headers := abstractions.NewRequestHeaders()
	headers.Add("Content-Type", "image/jpg")
	configuration := &applications.
		ItemLogoRequestBuilderPutRequestConfiguration{
		Headers: headers,
	}
	appLogo, err := os.ReadFile(appLogoFile)
	resp, err := client.Applications().ByApplicationId(appObjectID).Logo().Put(
		ctx,
		appLogo,
		configuration,
	)

However this results in the below error:
content type text/html does not have a factory registered to be parsed
On debugging further it was found that the APi call results in a a Bad Request 400 erro and the same is getting set in response body resulting in above error.
Looks like Content-tye is set to 2 values image/jpeg and application/octet-stream . Not sure if this is causeing the request to the MS graph API to fail

Activity

  1. rkodev commented on Jul 15, 2024

    @rkodev
    Contributor

    Hi ritu-rubrik , Thanks for trying the Graph Go SDK. Could you retry the code without setting the content header
    i.e remove the line explicitly setting content header headers.Add("Content-Type", "image/jpg")

    headers := abstractions.NewRequestHeaders()
    -	headers.Add("Content-Type", "image/jpg")
    	configuration := &applications.
    		ItemLogoRequestBuilderPutRequestConfiguration{
    		Headers: headers,
    	}
  2. ritu-rubrik commented on Jul 15, 2024

    @ritu-rubrik
    Author

    Hi Ronald K (@rkodev) I had initially tried it without setting the Content-Type

    headers := abstractions.NewRequestHeaders()
    	configuration := &applications.
    		ItemLogoRequestBuilderPutRequestConfiguration{
    		Headers: headers,
    	}
    	appLogo, err := os.ReadFile(appLogoFile)
    
    	resp, err := client.Applications().ByApplicationId(appObjectID).Logo().Put(
    		ctx,
    		appLogo,
    		configuration,
    	)
    
    

    However I ended up getting the below error which resulted in me adding the Content-Type:
    Content-Type was application/octet-stream. Image Content-Type header should be one of the following: [image/bmp, image/emf, image/wmf, image/jpg, image/jpeg, image/gif, image/ico, image/png, image/exif, image/tif, image/tiff, image/*, images/*].

  3. ritu-rubrik commented on Jul 15, 2024

    @ritu-rubrik
    Author

    Also one another question I have is if the response is Bad Request , why is it not getting set in OData Error as it is a 4XX status code, instead it is getting set in the response body which is leading to the initial error.content type text/html does not have a factory registered to be parsed

  4. rkodev commented on Jul 15, 2024

    @rkodev
    Contributor

    Thanks for pointing this out,

    1. I will be working on a solution on allowing users to override Content-Type which would be useful to in this case. As you correctly pointed out, whatever Content-Type header have right now, the sdk will override and set it to octet-stream. We will not be able to set the content type on the sdk at this moment as this SDK is "generated".

    2. Also I've noted the issue with the issue with error management. Issue seems to be the underlying service accepts a payload with content type 'application/json' but reports the error as 'text/html'. We will be working on that as well

  5. changed the title [-]Upload app logo resulet in Error[/-] [+]Upload app logo resulted in Error[/+] on Jul 16, 2024
  6. ritu-rubrik commented on Jul 16, 2024

    @ritu-rubrik
    Author

    Ronald K (@rkodev) Thanks for acknowledging the issue. Is there a timeline for this that I can expect for this change to be available?

  7. rkodev commented on Jul 17, 2024

    @rkodev
    Contributor

    ritu-rubrik The fix should be ready within the next 7 days

  8. baywet commented on Jul 17, 2024

    @baywet
    Member

    Ronald K (@rkodev) Can you open a corresponding issue in the metadata repo please?
    Fundamentally, the API description should not describe a media type for the request body if the service does not support it.
    Addressing the issue in the metadata emission phase would fix the issue for all generated clients, not just go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions