9

I'm currently building a Ruby SDK for the Graph API.

I'm working with delta queries on the message resource endpoints, specifically list-messages.

I need to specify two preferences utilizing the Prefer header(s):

  1. allow unsafe HTML - "outlook.allow-unsafe-html"
  2. maximum items per page/request - "odata.maxpagesize={num}"

There aren't any examples in the docs showing how this can be accomplished. I'm not sure whether they need to be concatenated into a single value or whether to specify multiple HTTP headers (or if this is even supported). Clarification here would be super helpful

wulymammoth
  • 8,121
  • 4
  • 19
  • 19
  • Is there a reason why you're not using the existing [Graph SDK for Ruby](https://github.com/microsoftgraph/msgraph-sdk-ruby)? – Marc LaFleur May 20 '19 at 14:25
  • @MarcLaFleur yeah, as indicated in the README, "This client library is a release candidate and is still in preview status. As such, this library is not production ready. Please proceed at your own risk and continue to provide feedback as we iterate towards a production supported library." It also doesn't support a feature that we need -- identifying a message resource if that resource has been moved by creating these resources with a single-value extended property providing a GUID upon creation. – wulymammoth May 20 '19 at 23:33
  • @MarcLaFleur could you lend light as to how I could accomplish the desired behavior? I made attempts to test this out using the Graph Explorer, but haven't been able to get the preference applied header to show up – wulymammoth May 20 '19 at 23:35

1 Answers1

13

According to RFC7240:

A client MAY use multiple instances of the Prefer header field in a single message, or it MAY use a single Prefer header field with multiple comma-separated preference tokens. If multiple Prefer header fields are used, it is equivalent to a single Prefer header field with the comma-separated concatenation of all of the tokens.

So you can use multiple Prefer header fields defining distinct preferences:

 POST /foo HTTP/1.1
 Host: example.org
 Prefer: respond-async, wait=100
 Prefer: handling=lenient
 Date: Tue, 20 Dec 2011 12:34:56 GMT

Or you may use a single Prefer header field with a comma-separated list of values:

 POST /foo HTTP/1.1
 Host: example.org
 Prefer: handling=lenient, wait=100, respond-async
 Date: Tue, 20 Dec 2011 12:34:56 GMT
Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
  • 1
    Thanks! Yeah, I just didn't know if Microsoft followed the spec. When I was testing it in your Graph Explorer, I didn't see the preference applied header (an indication that this is working) in either case. I dug around and came across a response from someone noting that that header is only returned if there is actual data that matches the preferences (all or nothing)? Is that a fair assumption? – wulymammoth May 21 '19 at 17:22
  • That is a pretty common way of handling `Preference-Applied`. That said, `Preference-Applied` isn't required by the spec so it is also possible it isn't being returned by Graph or the underlying Outlook/Exchange APIs. – Marc LaFleur May 22 '19 at 14:59