Skip to main content
Fixed language.
Source Link
Free Radical
  • 15.1k
  • 9
  • 48
  • 83

I am working with the module services 3 (D7) and I am calling the drupalDrupal method from a Java Clientclient. I can login (and keep the cessionsession in the cookie) and I can create a simple node...

But I can't set a Node Reference Field.

To find the way to do it, I first looked to the node structure (with the reference field) in my drupal site  :

 [field_presta_presta_suivi] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [nid] => 43
                    )

            )

    )

So, in my JavaClientJava Client, I created a function to reproduce this structure  :

public  static HashMap addReferenceField(String field, String language, String type_ref,Object value, HashMap node, int delta ){
        HashMap f = new HashMap();
        HashMap p = new HashMap();      
        Object[] i = new Object[delta+1];           
        HashMap val = new HashMap();
        
        val.put(type_ref, value);
        i[delta] = val;
        p.put(language, i);
        f.put(field, p);
        return f;
    }

This function is used to create a HashMap that will be add to the parameter of the service 'node.create'.

This function workworks with a User Refence Field (which has the same node struture), but when I used it for a node reference, the server returned "Not Acceptable".

I have already passed a lot of time on it and didn't find any example or similar case, so here my question  : How

How to you use services 3  (D7) to create a node with a node reference field ?

Thank you ^^

I am working with the module services 3 (D7) and I am calling the drupal method from a Java Client. I can login (and keep the cession in the cookie) and I can create a simple node...

But I can't set a Node Reference Field.

To find the way to do, I first looked to the node structure (with the reference field) in my drupal site  :

 [field_presta_presta_suivi] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [nid] => 43
                    )

            )

    )

So, in my JavaClient, I created a function to reproduce this structure  :

public  static HashMap addReferenceField(String field, String language, String type_ref,Object value, HashMap node, int delta ){
        HashMap f = new HashMap();
        HashMap p = new HashMap();      
        Object[] i = new Object[delta+1];           
        HashMap val = new HashMap();
        
        val.put(type_ref, value);
        i[delta] = val;
        p.put(language, i);
        f.put(field, p);
        return f;
    }

This function is used to create a HashMap that will be add to the parameter of the service 'node.create'.

This function work with a User Refence Field (which has the same node struture), but when I used it for a node reference, the server returned "Not Acceptable".

I have already passed a lot of time on it and didn't find any example or similar case, so here my question  : How to you use services 3(D7) to create a node with a node reference field ?

Thank you ^^

I am working with the module services 3 (D7) and I am calling the Drupal method from a Java client. I can login (and keep the session in the cookie) and I can create a simple node.

But I can't set a Node Reference Field.

To find the way to do it, I first looked to the node structure (with the reference field) in my drupal site:

 [field_presta_presta_suivi] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [nid] => 43
                    )

            )

    )

So, in my Java Client, I created a function to reproduce this structure:

public  static HashMap addReferenceField(String field, String language, String type_ref,Object value, HashMap node, int delta ){
        HashMap f = new HashMap();
        HashMap p = new HashMap();      
        Object[] i = new Object[delta+1];           
        HashMap val = new HashMap();
        
        val.put(type_ref, value);
        i[delta] = val;
        p.put(language, i);
        f.put(field, p);
        return f;
    }

This function is used to create a HashMap that will be add to the parameter of the service 'node.create'.

This function works with a User Refence Field (which has the same node struture), but when I used it for a node reference, the server returned "Not Acceptable".

I have already passed a lot of time on it and didn't find any example or similar case, so here my question:

How to you use services 3  (D7) to create a node with a node reference field ?

Tweeted twitter.com/#!/StackDrupal/status/267884422836142080
Source Link
user1241
user1241

Services 3 and Node Reference

I am working with the module services 3 (D7) and I am calling the drupal method from a Java Client. I can login (and keep the cession in the cookie) and I can create a simple node...

But I can't set a Node Reference Field.

To find the way to do, I first looked to the node structure (with the reference field) in my drupal site :

 [field_presta_presta_suivi] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [nid] => 43
                    )

            )

    )

So, in my JavaClient, I created a function to reproduce this structure :

public  static HashMap addReferenceField(String field, String language, String type_ref,Object value, HashMap node, int delta ){
        HashMap f = new HashMap();
        HashMap p = new HashMap();      
        Object[] i = new Object[delta+1];           
        HashMap val = new HashMap();
        
        val.put(type_ref, value);
        i[delta] = val;
        p.put(language, i);
        f.put(field, p);
        return f;
    }

This function is used to create a HashMap that will be add to the parameter of the service 'node.create'.

This function work with a User Refence Field (which has the same node struture), but when I used it for a node reference, the server returned "Not Acceptable".

I have already passed a lot of time on it and didn't find any example or similar case, so here my question : How to you use services 3(D7) to create a node with a node reference field ?

Thank you ^^