AnsweredAssumed Answered

Retrieving attachments from ArcGis Rest Service

Question asked by awigglesworth on Nov 27, 2014

Hi there,

 

I'm pretty new to the ArcGis rest services. I'm having problems determining when an attachment exists on a feature layer, and retrieving the attachment. I'm using C#, but accessing the feature layers through ArcGis Rest API. How do i get the Query layer to return the attachments along with the features that i can access. I'm able to navigate to them through the web browser but i can't get them through the API.

 

Below is the C# data mapping that i have laid out, everything else returns properly but the attachments do not.

 

namespace DataModels

{

    [DataContract]

    public abstract class FeatureLayer

    {

        [DataMember]

        public string objectIdFieldName { get; set; }

        [DataMember]

        public string globalIdFieldName { get; set; }

        [DataMember]

        public string geometryType { get; set; }

        [DataMember]

        public Spatialreference spatialReference { get; set; }

        [DataMember]

        public Field[] fields { get; set; }

    }

 

 

    [DataContract]

    public class Spatialreference

    {

        [DataMember]

        public int wkid { get; set; }

        [DataMember]

        public int latestWkid { get; set; }

    }

 

 

    [DataContract]

    public class Field

    {

        [DataMember]

        public string name { get; set; }

        [DataMember]

        public string type { get; set; }

        [DataMember]

        public string alias { get; set; }

        [DataMember]

        public string sqlType { get; set; }

        [DataMember]

        public Domain domain { get; set; }

        [DataMember]

        public object defaultValue { get; set; }

        [DataMember]

        public int length { get; set; }

    }

 

 

    [DataContract]

    public class Domain

    {

        [DataMember]

        public string type { get; set; }

        [DataMember]

        public string name { get; set; }

        [DataMember]

        public Codedvalue[] codedValues { get; set; }

    }

 

 

    [DataContract]

    public class Codedvalue

    {

        [DataMember]

        public string name { get; set; }

        [DataMember]

        public string code { get; set; }

    }

 

 

    [DataContract]

    public abstract class Feature

    {

        [DataMember]

        public Geometry geometry { get; set; }

        [DataMember]

        public Boolean hasAttachments { get; set; }

        [DataMember]

        public AttachmentInfos attachmentInfo { get; set; }

    }

 

 

    [DataContract]

    public abstract class Attributes

    {

        [DataMember]

        public int OBJECTID { get; set; }

    }

 

 

    [DataContract]

    public class Geometry

    {

        [DataMember]

        public float x { get; set; }

        [DataMember]

        public float y { get; set; }

    }

 

 

    [DataContract]

    public class AttachmentInfos

    {

        [DataMember]

        public Attachments[] attachments;

    }

 

 

    [DataContract]

    public class Attachments

    {

        [DataMember]

        public string id { get; set; }

        [DataMember]

        public string contentType { get; set; }

        [DataMember]

        public int size { get; set; }

        [DataMember]

        public string name { get; set; }

    }

}

 

JSON query:

StringBuilder sb = new StringBuilder(requestLayer);

            sb.Append("query?");

            sb.Append("where=RequestID<>''&");

            sb.Append("returnCountOnly=false&");

            sb.Append("returnIdsOnly=false&");

            sb.Append("outFields=OBJECTID,RequestID,Description,CustomerNumber,Note,Employee&");

            sb.Append("token=" + token);

Outcomes