Gemini Community Support Site

This Gemini community support site can be used to find solutions to product issues. You can log in using Open Id, Google Profile and even Facebook. Feel free to ask a question or browse FAQs and documentation. Product tour videos are also available along with how-to videos demonstrating key Gemini capabilities.




Creating components via rest, parentComponentID needs to be NULL...

api

Hi,

I'm trying to use the rest API to create a component on a project.

When I check the components in Gemini they exist but don't appear on any of the UI features apart from the admin screen.

When I checked the database I noticed their parentComponentID was 0 (if I pass 0) and not NULL like the rest. If I edit the component in the gemini admin and just update without changing anything the record in the database switches to NULL instead of 0 and then appears on all the front ends.

I've tried passing 'NULL' and '0' but they just store '0' in the field; I tried leaving that node empty in the xml so it was just [ParentComponentID][/ParentComponentID] but that generates the following error:

[?xml version="1.0" encoding="utf-8"?][RestError xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"][Exception][InnerMessage]Object reference not set to an instance of an object.[/InnerMessage][InnerSource]CounterSoft.Gemini.Presenter[/InnerSource][InnerStack] at CounterSoft.Gemini.Presenter.ProjectPresenter.CreateComponent(ComponentEN data) at CounterSoft.Gemini.Web.Api.ProjectsRestHandler.ComponentCreate(RequestDetails rd)[/InnerStack][InnerType]System.NullReferenceException[/InnerType][Message]Exception has been thrown by the target of an invocation.[/Message][Source]mscorlib[/Source][Stack] at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at CounterSoft.Gemini.Web.Api.x984df3e201a5cc4a.xd8c6760a50aeba18(RequestDetails x4f7dd955f6bfaf92, MethodInfo x2a154456227d18a2)[/Stack][Type]System.Reflection.TargetInvocationException[/Type][/Exception][Message]Exception has been thrown by the target of an invocation.[/Message][Type]InternalServerError[/Type][/RestError]

If I leave the XML node out entirely it defaults to using 0! Am I just going about this in the wrong way??

light2
· 1
light2
Replies (9)
helpful
0
not helpful

Sorry, a bit confused here.

Are you saying that you can create a component but not update? The exception seem to come from creation.

Which version of Gemini?

Are you using our webservices proxy?


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

I can create the component but the components parentComponentID is set to '0' not NULL; The component exists but it appears for the component to exist as a root level component it's parent must be null.

I think I have to send somthing like xsi:nill="true" in the node attribute but doesn't seem to work; maybe I need the full attributes in the header too?

Version (v3.5.4 (Build 2435)

Using the rest web services (/api/...)


light2
· 1
light2
helpful
0
not helpful

Yep. I added the xsi and xsd headers into the first node and that appears to fix it :-p

    $root->setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
    $root->setAttribute('xmlns:xsd','http://www.w3.org/2001/XMLSchema');

And on the actual element that is null

    $node->setAttribute('xsi:nil', "true");

light2
· 1
light2
helpful
0
not helpful

Probably would be good to add it somewhere in the documentation - I'm not sure if that is .NET convention or general XML.


light2
· 1
light2
helpful
0
not helpful

This works for us:

<?xml version="1.0" encoding="utf-8"?><ComponentEN xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="NoChange2008-01-31T16:34:30AAAAAAAACDA=28Test CmpDatabase'>http://www.w3.org/2001/XMLSchema"><State>NoChange</State><DateCreated>2008-01-31T16:34:30</DateCreated><TimeStamp>AAAAAAAACDA=</TimeStamp><ProjectID>2</ProjectID><ComponentID>8</ComponentID><ComponentName>Test Cmp</ComponentName><ComponentDesc>TestCMP</ComponentDesc><ComponentReadOnly>false</ComponentReadOnly><ComponentReadOnlyS>N</ComponentReadOnlyS><UserID>2</UserID><ParentComponentID xsi:nil="true" /></ComponentEN>


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

Actually; My Object to XML function is based on the one in the Java example and checking the Java method again (BaseEN::toXML) it doesn't seem to do any handling of nulls - apart from ignoring them.

I guess the java example would fail at passing nulls too?


light2
· 1
light2
helpful
0
not helpful

Yep; I was passing the "xsi:nil" attribute but not specifying the schemas in the root node; I guess it needs to know what xsi:nil means before it can use it.


light2
· 1
light2
helpful
0
not helpful

We will have to investigate it. Did you see my previous post?


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

Yep; sorry - It's all working now;

I've amended my "toXML" method to check for null types and insert this "xsi:nil" into the xml;


light2
· 1
light2