1

I have setup Redmine locally. I want to Get and Post data on Red mine in order to test my Extjs application. Redmine RestApi support is available. This link show all the issue on Redmine available http://www.redmine.org/issues.json

Problem is that it is padded with word "issues" due to which I can't read it via simple Json type reader in Extjs. I guess JSONP can provide some solution but I am not able to figure out how? Can any help by telling how to get simple JSON without and padded word?

Here is my Extjs app Model:

Ext.define('ThemeApp.model.peopleModel', {
extend: 'Ext.data.Model',

fields: [
    { name: 'id' },

    { name: 'subject' },

    { name: 'description'}
],

proxy: {
    type: 'rest',
    format: 'json',
    limitParam:"",
    filterParam: "",

    url:'http://www.redmine.org/issues.json',

    //headers: {'Content-Type': "application/json" },
    //url : 'http://api.soundcloud.com/tracks?q=allah%20dita%20rehman%20khan&client_id=0b19b8dc2526b43eae19f03b2eab6798&format=json&_status_code_map[302]=200'

    reader: {
    type: 'json',
    rootProperty:'issues'
    },
    writer: {
        type: 'json'
    }

}});

Error in Browser Console is Browser Error

Abdul Rehman Yawar Khan
  • 1,088
  • 3
  • 17
  • 40

1 Answers1

3

Redmine returns valid JSON (as can be checked here), so the ExtJS JSON reader can read it without a problem.

You will just have to tell him where to search, by setting the root property (ExtJS 4) or the rootProperty property (ExtJS 5) on the reader.

ExtJS4:

reader:{
    type:'json',
    root:'issues'
}

ExtJS5:

reader:{
    type:'json',
    rootProperty:'issues'
}
Alexander
  • 19,906
  • 19
  • 75
  • 162
  • Thanks, I didn't understand the rootProperty Property properly, But I still can't access data, Now my browser console shows this error: "Image is attached in Updated Question" – Abdul Rehman Yawar Khan Mar 24 '15 at 14:29
  • What error? I don't see it. But my best guess would be that you are not allowed to read JSON data from a different domain. – Alexander Mar 24 '15 at 14:33
  • I am using CORS Chrome extension to read data from different domain. I have tried reading Soundcloud api and It worked properly, but with Redmine I am facing issues. – Abdul Rehman Yawar Khan Mar 24 '15 at 14:35
  • @YawarKhan In the image, I see that you are trying to request `issues.json.json`. IIRC the link is `issues.json`. This would of course yield a `404`. – Alexander Mar 26 '15 at 17:01