flickr-net icon indicating copy to clipboard operation
flickr-net copied to clipboard

PhotosGetInfo throwing InvalidOperationException

Open strandloper opened this issue 2 years ago • 1 comments

The PhotosGetInfo method has recently (since 2022-11-10) started throwing EnvalidOperationException with message "The ReadContentAsString method is not supported on node type Element. If you want to read typed content of an element, use the ReadElementContentAs method. Line 46, position 4."

strandloper avatar Nov 12 '22 14:11 strandloper

This is caused by an apparent data error. It happened for PhotoId 52491349517 that somehow has a "null" tag. On the website this looks like this image and the XML, including the preceding and following tags is

<tag id="135791234-52491349517-4511" author="135836556@N06" authorname="Mandir Prem" raw="theatre" machine_tag="0">theatre</tag>
<tag id="135791234-52491349517-532610616" author="135836556@N06" authorname="Mandir Prem" raw="" machine_tag="0" />
<tag id="135791234-52491349517-532683991" author="135836556@N06" authorname="Mandir Prem" raw="П" machine_tag="0">п</tag>

This results in

TagText = reader.ReadContentAsString();

failing because reader.NodeType is Element whereas Text is expected. Changing the line to

TagText = reader.NodeType == XmlNodeType.Text ? reader.ReadContentAsString() : null;

resolves the problem.

strandloper avatar Nov 12 '22 19:11 strandloper