1
votes

I have a Drupal Views 2 view that returns a number of fields for some nodes as JSON. I can view it in Chrome, and it has everything I expect.

When I download it on my Windows Phone 7 app, one field, "field_images_nid" is mysteriously missing from the response. What could have caused this? Does Drupal not send that field because of some user agent data on WP7's WebClient?

        WebClient data = new WebClient();
        data.DownloadStringCompleted += new DownloadStringCompletedEventHandler(onComplete);
        data.DownloadStringAsync(new Uri(dataUri));

The field in question is a link to an image associated with the node. Views refers to it as "Content: Images Full Node".

Update: I made a new test app that does nothing but make the request so I can view the result in a debugger:

public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();

        Loaded += new RoutedEventHandler(MainPage_Loaded);
    }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        WebClient client = new WebClient();
        client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
        client.DownloadStringAsync(new Uri("http://path/to/service"));
    }

    void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        string result = e.Result;
    }
}

I made a new view that does nothing but return "Title" and "Content: Images (full node)" for a given nid. I am able to observe the same incongruence between the Chrome and WP7 request.

Update 2: When I go to the views url in Chrome incognito, the field is not returned. Perhaps there is a permissions issue at work? I thought the field should be anonymously available.

1
If you look at the traffic with Fiddler (or similar) what's different in the request and response for the Chrome and WP7 requests?Matt Lacey
The request doesn't show up in Fiddler, actually (from the emulator). Perhaps I'm doing something wrong?Nick Heiner
If I make a request from Fiddler (with user-agent set to Chrome or WP7), the response still misses the field I'm looking for.Nick Heiner
See blogs.msdn.com/b/fiddler/archive/2010/10/15/… for using Fiddler with the emulator. It sounds like you need to confirm the behaviour on the server side if it's not returning the data you expectMatt Lacey

1 Answers

0
votes

Turns out the problem was server side. When I was testing it in my browser, I was always logged in. Making the content type available anonymously solved the issue.