cancel
Showing results for 
Search instead for 
Did you mean: 

Null Reference Exception in File Management Extended C#

BohyonHwang
Level 9
kh_placeholder.png
I'd tried to get an internet image file in the binary data item directly.
Utility - File Management [Extended C#] seemed to have the right action as 'Download File as Binary'.
But the action returned False Success even if HTTP Status Code equals 200 - OK.

What's wrong with my code?
A screenshot is attached.
Thanks in advance.
1 BEST ANSWER

Helpful Answers

GeoffHirst
Staff
Staff
Hi @Bohyon Hwang,

Thank you for using Blue Prism.

The problem seems to be that the code in the download elements is relying on a response header called Content-Disposition. Now, it seems that its null, hence the null exception you are getting when the process tries to retrieve the filename.

Now, if you are familiar with C#, you could just edit the code as shown below:

if (responseMessage.Content.Headers.ContentDisposition != null)
{
fileName = responseMessage.Content.Headers.ContentDisposition.FileNameStar;
}

This code can be found on the code page of the Download File As Binary action. The downside is that in this example the filename will not be returned. I will need to spend more time to see how this might be resolved in full. In the interim, I hope this helps.

Once again, thank you for being an SS&C Blue Prism user.

regards

Geoff HIrst

SR DX Engineer, Integration and Enablement, Blue Prism Digital Exchange


-- Further Note. The problem may actually be that the website isn't responding how it should be. This link explains the header that is the issue here https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition.

If you try to download from another site, do you get the same problem?



Geoff Hirst Senior DX Engineer - Digital Exchange - EMEA SS&C Blue Prism

View answer in original post

3 REPLIES 3

BohyonHwang
Level 9
Image is attached again.

GeoffHirst
Staff
Staff
Hi @Bohyon Hwang,

Thank you for using Blue Prism.

The problem seems to be that the code in the download elements is relying on a response header called Content-Disposition. Now, it seems that its null, hence the null exception you are getting when the process tries to retrieve the filename.

Now, if you are familiar with C#, you could just edit the code as shown below:

if (responseMessage.Content.Headers.ContentDisposition != null)
{
fileName = responseMessage.Content.Headers.ContentDisposition.FileNameStar;
}

This code can be found on the code page of the Download File As Binary action. The downside is that in this example the filename will not be returned. I will need to spend more time to see how this might be resolved in full. In the interim, I hope this helps.

Once again, thank you for being an SS&C Blue Prism user.

regards

Geoff HIrst

SR DX Engineer, Integration and Enablement, Blue Prism Digital Exchange


-- Further Note. The problem may actually be that the website isn't responding how it should be. This link explains the header that is the issue here https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition.

If you try to download from another site, do you get the same problem?



Geoff Hirst Senior DX Engineer - Digital Exchange - EMEA SS&C Blue Prism

BohyonHwang
Level 9
The problem is solved with the help of Mr Geoff Hirst.
The data item can be filled with the correct data I wanted.
It also works for downloading another website.
Thank you so much.