# Plex XML API Inconsistent

**URL:** <https://forums.plex.tv/t/plex-xml-api-inconsistent/12491>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [November 18, 2011, 5:27pm UTC](https://forums.plex.tv/t/plex-xml-api-inconsistent/12491 "2011-11-18T17:27:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alon.albert](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@alon.albert](https://forums.plex.tv/u/alon.albert)\
**Post date:** [November 18, 2011, 5:27pm UTC](https://forums.plex.tv/t/plex-xml-api-inconsistent/12491/1 "2011-11-18T17:27:14Z")

</div>

I’ve noticed a strangeness with the Plex XML API. I drill into a metadata node for an item and fetch it’s XML, for example: [http://localhost:32400/library/metadata/4695](http://localhost:32400/library/metadata/4695)  
  
  
  
The Video element has an attribute viewCount=1 and has no lastViewedAt attribute. When I reload the same page, the lastViewedAt attribute appears in the xml.  
  
  
  
I’ve seen this happen with the guid attribute also. I happen the have the entire xml for the guid example:  
  
  
  
first time I load the xml:  
  
  
  
[xml]\<?xml version="1.0" encoding="UTF-8"?\>  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
[/xml]  
  
  
  
Second time:  
  
  
  
[xml]\<?xml version="1.0" encoding="UTF-8"?\>  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
[/xml]  
  
  
  
All I did was reload the page. The first version doesn’t have a guid attribute while the second one does.

---

<div class="post-metadata">

**Author:** ![alon.albert](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@alon.albert](https://forums.plex.tv/u/alon.albert)\
**Post date:** [November 18, 2011, 10:54pm UTC](https://forums.plex.tv/t/plex-xml-api-inconsistent/12491/2 "2011-11-18T22:54:13Z")

</div>

My code now does something like this:

```auto

<br />
xml = getXml();<br />
lastViewedTime = getLastViewedTimeFromXml(xml);<br />
if (lastViewedTime == "") {<br />
  xml = getXml();<br />
  lastViewedTime = getLastViewedTimeFromXml(xml);<br />
}<br />

```

  
  
Which works but seems like a silly thing to have to do.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 9:26pm UTC](https://forums.plex.tv/t/plex-xml-api-inconsistent/12491/3 "2019-12-20T21:26:44Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
