I am using Breeze with a SharePoint Online list, which support attachments. The Breeze query, correctly calls expand and I can see through Browser and Fiddler, that JSON is returned with the attachment data in it. However, the entities created in Breeze JavaScript don't contain data for AttachmentFiles. Its always Null. Is this something the SP Adapter just doesn't support, or am I defining the AttachmentFiles and List entities incorrectly. I have tried numerous ways to define relationship, using complextype and navigation, with autogen ID and without, but I am coming up stumped.
Rest Request looks like this: /_api/web/lists/getbytitle('Contacts')/items?$expand=Author/Id,AttachmentFiles&$select=Id,AuthorId,FirstName,Title,Email,Author,AttachmentFiles ,Author/UserName
Attached is a view of the JSON returned, and the current Breeze entities mapped.
Snippet from entities
//attachments
addType({
name: 'AttachmentFiles',
dataProperties: {
ServerRelativeUrl: {
nullable: false
},
FileName: {
nullable: false
}
}
});
// create entity for contacts
addType({
name: 'Contacts',
defaultResourceName: 'getbytitle(\'Contacts\')/items',
dataProperties: {
Id: {
type: breeze.DataType.Int32
},
AuthorId: {
type: breeze.DataType.Int32
},
FirstName: {
nullable: false
},
Title: {
nullable: false
}, // this is actually the last name field in the list
Email: {
nullable: false,
validators: [breeze.Validator.emailAddress()]
},
Author: {
complexTypeName: "Author"
}
},
// Let model.validation add the requireReferenceEntity validators
navigationProperties: {
AttachmentFiles: {
type: 'AttachmentFiles',
hasMany: true
}
}
});
See JSON response below
{
"d": {
"results": [
{
"__metadata": {
"id": "388762a5-a565-4033-af90-5a2ea4cb1894",
"uri": "https://foo-616175366e015f.sharepoint.com/sites/DevSIte/BreezeSP2013Sample/_api/Web/Lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/Items(1)",
"etag": "\"3\"",
"type": "SP.Data.ContactsListItem"
},
"AttachmentFiles": {
"results": [
{
"__metadata": {
"id": "https://foo-616175366e015f.sharepoint.com/sites/DevSIte/BreezeSP2013Sample/_api/Web/Lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/Items(1)/AttachmentFiles('8328787dc792224f625c9645a45d01aa.jpg')",
"uri": "https://foo-616175366e015f.sharepoint.com/sites/DevSIte/BreezeSP2013Sample/_api/Web/Lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/Items(1)/AttachmentFiles('8328787dc792224f625c9645a45d01aa.jpg')",
"type": "SP.Attachment"
},
"FileName": "8328787dc792224f625c9645a45d01aa.jpg",
"ServerRelativeUrl": "/sites/DevSIte/BreezeSP2013Sample/Lists/Contacts/Attachments/1/8328787dc792224f625c9645a45d01aa.jpg"
},
{
"__metadata": {
"id": "https://foo-616175366e015f.sharepoint.com/sites/DevSIte/BreezeSP2013Sample/_api/Web/Lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/Items(1)/AttachmentFiles('Screen Shot 2015-04-23 at 10.28.35 AM.png')",
"uri": "https://foo-616175366e015f.sharepoint.com/sites/DevSIte/BreezeSP2013Sample/_api/Web/Lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/Items(1)/AttachmentFiles('Screen%20Shot%202015-04-23%20at%2010.28.35%20AM.png')",
"type": "SP.Attachment"
},
"FileName": "Screen Shot 2015-04-23 at 10.28.35 AM.png",
"ServerRelativeUrl": "/sites/DevSIte/BreezeSP2013Sample/Lists/Contacts/Attachments/1/Screen Shot 2015-04-23 at 10.28.35 AM.png"
}
]
},
"Author": {
"__metadata": {
"id": "1fdc1547-d439-42bd-b3aa-b41e92c8ec6f",
"type": "SP.Data.UserInfoItem"
},
"UserName": "[email protected]"
},
"Id": 1,
"ID": 1,
"Title": "Alanso",
"AuthorId": 1073741823,
"FirstName": "Fernando",
"Email": "[email protected]"
}
]
}
}