I've installed this great package on a fresh Umbraco v7.1.8.
So far I've used the XML CheckBox Picker with content, for users to pick categories from nodes in the content tree. Works perfect.
Now I have to render some checkbox lists with data from a service returning JSON. So I made a new data type using the JSON CheckBox Picker.
But unfortunately I'm not getting anything in return in the data type. In my concole I'm getting an error when calling: "http://myproject.local/umbraco/backoffice/nuPickers/JsonDataSourceApi/GetEditorDataItems?contextId=1078&propertyAlias=jsonPicker"
saying:
)]}',
{"Message":"The requested resource does not support http method 'GET'."}
I've tried with both a local json-file and with the URL to the service that provides me with the real JSON.
My local json file looks like this:
Just for testing purpose I tried placing the js-file containing the JSON array in the root of the website, so in the url i had tried both of these paths:
I have also tested the above - but keep getting this error:
)]}', {"Message":"The requested resource does not support http method
'GET'."}
I am trying to fetch json data via an external web-api service (which we also have implemented ourselves). CORS is enabled on the service and tested to be ok. The controller should respond to both GET and POST. The service returns this:
Hi Zac, any chance you would be able to debug to pinpoint a more spcific error ? (I'm wondering if the GetContents(string url) method in JsonDataSource.cs is working correctly)
We just spent a good hour trying every combination of JSONPath, Key and Label.
The 500 error comes up as soon as you touch the node with the property on it. The error looks like this, regardless of what you put into the settings for the data type:
)]}',
{"Message":"An error has occurred.","ExceptionMessage":"Error reading string. Unexpected token: StartObject. Path '[0]', line 1, position 2.","ExceptionType":"Newtonsoft.Json.JsonReaderException","StackTrace":" at Newtonsoft.Json.JsonReader.ReadAsStringInternal()\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)\r\n at Newtonsoft.Json.Linq.JToken.ToObject[T]()\r\n at nuPickers.Shared.JsonDataSource.JsonDataSource.GetEditorDataItems(Int32 contextId)\r\n at nuPickers.Shared.JsonDataSource.JsonDataSourceApiController.GetEditorDataItems(Int32 contextId, String propertyAlias, Object data)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)"}
That is the response from /umbraco/backoffice/nuPickers/JsonDataSourceApi/GetEditorDataItems?contextId=1060&propertyAlias=pickertest
The only way I've been able to get this picker working was with a simple Array of strings for the JSON object, and blank key/label settings.
Separate note - using ~/ does not work unless you are referencing the file system. Maybe this is intended but it took me a while to realise that I couldn't use ~/ for a relative URL as the field description does explicitly say "relative url".
I really hope we can solve this as the tool looks like it will be seriously amazing.
Do you think you could let me know whether you think this is an issue you'll be able to look into any time soon?
Totally understand if you can't get around to it, I'd just like to know whether to expect a solution during the project I'm currently working on! If not I can probably use the DotNet data source instead :)
I was using XML checkboxpicker, and had it all working with a custom label, but it broke when updating from umbraco 7.2.1 to 7.2.2 (nighlty build v.9).
The only picker I now could get to work, was the XML checkboxpicker, but without custom labels. When using JSON chekcbox picker or using a custom label on the XML checkboxpicker, I got the same errors on JsonDataSourceApi/GetEditorItems and XMLDataSourceApi/GetEditorItems.
So i tried to update to nightly build v.18 but without success. Then I overwrote the ClientDependency.config with a clean out-of-the-box version, and all is now fixed and working!
So it seems to be some error in the stack compiled by ClientDependency?
Yes I was - it's caused due to the fact that if the source JSON is an array, then it's expecting an array of strings - will hopefully have a fix for this pushed this week.
Currently thinking along the lines of: (does this sound like a sensible approach ?)
1) if an array of strings then use those strings for both the key / label (ignore any JsonPaths)
2) if an array of objects of type: { 'key' : 1, 'label: 'item 1' } use these objects (ignore any JsonPaths)
Hi Hendy, yes that approach does indeed sound very sensible!
Thank you for this, really. nuPickers is absolutely killer - loving the DotNetDataSource too. Between this and Archetype we have so much functionality these days with so little code.
Error getting JSON CheckBox Picker to work
Hi all
I've installed this great package on a fresh Umbraco v7.1.8.
So far I've used the XML CheckBox Picker with content, for users to pick categories from nodes in the content tree. Works perfect.
Now I have to render some checkbox lists with data from a service returning JSON. So I made a new data type using the JSON CheckBox Picker.
But unfortunately I'm not getting anything in return in the data type. In my concole I'm getting an error when calling: "http://myproject.local/umbraco/backoffice/nuPickers/JsonDataSourceApi/GetEditorDataItems?contextId=1078&propertyAlias=jsonPicker" saying:
I've tried with both a local json-file and with the URL to the service that provides me with the real JSON. My local json file looks like this:
But unfortunately I'm still getting the error :(
In the "Key JSONPath" I have the following: TypeId and in the "Label JSONPath" I have the TypeName
Anyone knows what I have to do to get It working?
Thanks in advance.
/Kim A
Hi Kim,
What value do you have configured for the url, and does this respond correctly with JSON ?
Just a thought, but If it's a remote url, can the server resolve it correctly ?
Hendy
Hi Hendy
Just for testing purpose I tried placing the js-file containing the JSON array in the root of the website, so in the url i had tried both of these paths:
~/json.json
http://myproject.local/json.json
But I'm getting the samme error either way.
In the JSONPath property i have the following: $..*
Don't know if that helps? Or you need to know anything else about the setup?
/Kim A
Hi Hendy
I have also tested the above - but keep getting this error:
I am trying to fetch json data via an external web-api service (which we also have implemented ourselves). CORS is enabled on the service and tested to be ok. The controller should respond to both GET and POST. The service returns this:
The json should be valid.
The datatype uses the custom editor "nuPicker:json checkbox picker" and is configured as follows:
I have tried on a clean Umbraco v 7.1.8 but the error is the same and like Kim i get can see this error in the console:
Am i doing something completely wrong here or?
Thanks in advance!
/Emil
Same exact issue here
Hi Zac, any chance you would be able to debug to pinpoint a more spcific error ? (I'm wondering if the GetContents(string url) method in JsonDataSource.cs is working correctly)
Hi Hendy.
We just spent a good hour trying every combination of JSONPath, Key and Label.
The 500 error comes up as soon as you touch the node with the property on it. The error looks like this, regardless of what you put into the settings for the data type:
)]}', {"Message":"An error has occurred.","ExceptionMessage":"Error reading string. Unexpected token: StartObject. Path '[0]', line 1, position 2.","ExceptionType":"Newtonsoft.Json.JsonReaderException","StackTrace":" at Newtonsoft.Json.JsonReader.ReadAsStringInternal()\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)\r\n at Newtonsoft.Json.Linq.JToken.ToObject[T]()\r\n at nuPickers.Shared.JsonDataSource.JsonDataSource.GetEditorDataItems(Int32 contextId)\r\n at nuPickers.Shared.JsonDataSource.JsonDataSourceApiController.GetEditorDataItems(Int32 contextId, String propertyAlias, Object data)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)"}
That is the response from
/umbraco/backoffice/nuPickers/JsonDataSourceApi/GetEditorDataItems?contextId=1060&propertyAlias=pickertest
The only way I've been able to get this picker working was with a simple Array of strings for the JSON object, and blank key/label settings.
Separate note - using
~/
does not work unless you are referencing the file system. Maybe this is intended but it took me a while to realise that I couldn't use~/
for a relative URL as the field description does explicitly say "relative url".I really hope we can solve this as the tool looks like it will be seriously amazing.
Also, for sanity and future reference, let's say we're using the following JSON:
http://beta.json-generator.com/KapqN6a
Hi again Hendy,
Do you think you could let me know whether you think this is an issue you'll be able to look into any time soon?
Totally understand if you can't get around to it, I'd just like to know whether to expect a solution during the project I'm currently working on! If not I can probably use the DotNet data source instead :)
Hi Zac, I started looking into this yesterday - I think the issue might be in the GetContents() method in https://github.com/uComponents/nuPickers/blob/master/source/nuPickers/Shared/JsonDataSource/JsonDataSource.cs
I'm guessing you meant the GetEditorDataItems method? Although I can see why we were having the relative url issues in GetContents():
E.g. maybe it should be something like
url = url.Replace("~/", HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)) + "/")
I was using XML checkboxpicker, and had it all working with a custom label, but it broke when updating from umbraco 7.2.1 to 7.2.2 (nighlty build v.9).
The only picker I now could get to work, was the XML checkboxpicker, but without custom labels. When using JSON chekcbox picker or using a custom label on the XML checkboxpicker, I got the same errors on JsonDataSourceApi/GetEditorItems and XMLDataSourceApi/GetEditorItems.
So i tried to update to nightly build v.18 but without success. Then I overwrote the ClientDependency.config with a clean out-of-the-box version, and all is now fixed and working!
So it seems to be some error in the stack compiled by ClientDependency?
Hi, can't say that's an issue I've encountered, but good to hear it's all working again.
Hey Hendy,
Were you able to reproduce the error with the http://beta.json-generator.com/KapqN6a JSON feed?
Hi Zac,
Yes I was - it's caused due to the fact that if the source JSON is an array, then it's expecting an array of strings - will hopefully have a fix for this pushed this week.
Currently thinking along the lines of: (does this sound like a sensible approach ?)
1) if an array of strings then use those strings for both the key / label (ignore any JsonPaths)
2) if an array of objects of type: { 'key' : 1, 'label: 'item 1' } use these objects (ignore any JsonPaths)
3) apply JsonPath (re-check condition 1, re-check condition 2)
4) apply KeyJsonParth and LabelJsonPath
HTH,
Hendy
Hi Zac,
Both issues (locally served json without a file on the file system / handling an array of objects) should now be fixed.
Here's a link to the latest NuGet build: https://www.myget.org/gallery/nupickers
Hendy
Hi Hendy, yes that approach does indeed sound very sensible!
Thank you for this, really. nuPickers is absolutely killer - loving the DotNetDataSource too. Between this and Archetype we have so much functionality these days with so little code.
Thanks :) hope it's all working now... (will have a full release out soon)
is working on a reply...