Error with setRequestHeader on XMLHttpRequest

#1

Getting an error making an http request in my plugin:
Failed to execute \'setRequestHeader\' on \'XMLHttpRequest\': name and/or value is not for header

We do have some custom headers we are setting. Are these not allowed? Is it something else?

Thanks

#2

I have more info. The header it doesn’t like is content-disposition.

The request I’m making is to upload file data so I’m setting the content-disposition with a value of "attachment; filename="" + uploadFilename + "\"". This all worked in a previous version of XD. Is this not allowed now?

#3

@kerrishotts Is there any UXP change recently that might have caused this to stop working?

#4

Double check that there are no special characters in your filename – headers can only contain a subset of the ASCII standard. If you need to accept characters outside this range, you’ll need to encode the header and decode it on the other side.

Also double check that your filename doesn’t contain multiple spaces in a row.

Note: this checking is due to the addition of FormData support. Versions prior to XD 18 did not support FormData and as such did not have this additional check logic.

#5

Yes, it was the filename that it didn’t like. We are trying to use the Artboard name as the filename. I already run it through a sanitizer but I’m not checking for double spaces. I’ll expand the sanitizer to remove extra spaces and see if that helps.

Thanks

edit - Yes it was the double spaces in the filename. I expanded the filename sanitizer to trim those down to a single space and the uploads work again.