Get Started         Best Practices         Developer Guide         FAQ        
Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

retrieving something from "custom" field

Kent Jan 16, 2018

Catchoom,

My app successfully puts a string in the "custom" parameter when creating an item, but I am not able to retrieve it correctly. I know it is there because 1) it appears in the Optional Data "Text Field" in my collection via your Collection Management Dashboard (note: I'm not sure why this isn't labeled "Custom Field" to match your documentation), and 2) when I run the Curl command for Get Item it returns as part of the "Custom : string" data pair. I am able to retrieve the other Item parameter data, as well as Score and Image parameters, but the Custom field returns a web Url. Ex. https://craftar-us.s3.amazonaws.com/collections/907788caaebd422c837b654da187c6da/metadata/973f2a2c8f034757af4ad08380dcfbb3.json. When I click on this link the data I'm looking for appears in my browser. I expected to be able to simply retrieve the data like I can for other paramaters, but I get this link instead.

Here is my code where you'll see I'm trying various approaches simultaneously. Below that are the results. Can you help me understand how to get at the "custom data" properly? Thanks, Kent

CraftARResult result = results.get(0);
int result1 = results.get(0).getScore();
String name1 = results.get(0).getItem().getItemName();
JSONObject itemJSON = result.getItem().getJson();
String firebaseItemUUID = result.getItem().getCustom();

********************************************************
Both of these yield the same thing for.. itemJSON:

JSONObject itemJSON = result.getItem().getJson();
String stringJsonItem = itemJSON.toString();
{"uuid":"973f2a2c8f034757af4ad08380dcfbb3","url":"http:\/\/en.wikipedia.org\/wiki\/The_Birth_of_Venus_(Botticelli)","custom":"https:\/\/craftar-us.s3.amazonaws.com\/collections\/907788caaebd422c837b654da187c6da\/metadata\/973f2a2c8f034757af4ad08380dcfbb3.json","content":null,"trackable":false,"images":["51c6a3ca08e84dbdb23023aae38e10a2"],"name":"4647rui"}

*****************************************************
String fb = (String) itemJSON.opt("custom");
https://craftar-us.s3.amazonaws.com/collections/907788caaebd422c837b654da187c6da/metadata/973f2a2c8f034757af4ad08380dcfbb3.json

loading the above link in the browser yields the "custom data" parameter I'm looking for ---> 7cd141f9-416a-4b8a-803c-86f11974f904

1 Community Answers

Best Answer
Kent

Jan 16, 2018

I figured it out after finding a reference to embed custom in the V0 documentation. Then a search on embed custom and a dive into the CraftarAR classes led me to add to my search code. True retrieves the value directly, while False returns just the URL which is quicker if you don't need the data immediately and don't want to slow down the search results. Hope this helps someone else.

mCloudIR.setEmbedCustom(true);


Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Couldn't find what you were looking for?

support@catchoom.com
https://cdn.desk.com/
false
catchoom
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete