Search Unity

[RELEASED] Drupal API

Discussion in 'Assets and Asset Store' started by bdovaz, Aug 28, 2016.

  1. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    197

    Much obliged for help. Currently the client put the project on hold, but probably I will be resuming it shortly. My guess is I misconfigured it at some point due to lack of knowledge, so probably your tips will solve this. Anyway, I will give feedback here when possible. Thanks!
     
  2. jirimotejlek

    jirimotejlek

    Joined:
    Nov 8, 2016
    Posts:
    7
    Hi, first, thank you for an amazing asset.
    I would like to implement an endpoint in C# for services view but I don't know where to begin. The example in CustomExampleResources.cs doesn't really help with this as it's very basic and deals with creating nodes. Can you give me any hints about how to start coding this?
     
  3. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    733
    If I'm not wrong resources created with services views modules are only to retrieve information (GET request) and the example "CustomExampleResource.cs" creates a node (POST request).



    In my personal opinion it's better to create your custom resources:

    https://www.drupal.org/node/783460
    http://docs.drupalgap.org/7/Services/Create_a_Custom_Service

    In case you will still want to use services views here you have information about passing arguments (in case you need that):

    https://www.drupal.org/project/services/issues/1513348
    https://drupal.stackexchange.com/qu...ass-contextual-filters-to-a-view-via-services
    https://drupal.stackexchange.com/questions/9061/how-to-access-services-views-the-correct-way

    In my source code you can see how I implement each resources and how you could replicate it for a custom service view resource:

    Code (CSharp):
    1.  
    2. namespace Drupal {
    3.  
    4.     public partial class DrupalAPI {
    5.  
    6.         public void GetCustomData(uint id) {
    7.             string uri = string.Format("http://example.com/api/my_endpoint&args[0]={0}", id);
    8.  
    9.             Get(false, uri,
    10.                 (response) => {
    11.                     MyCustomClass data = DeserializeInstance<MyCustomClass>(response);
    12.                 }
    13.             );
    14.         }
    15.  
    16.     }
    17.  
    18. }
    19.  
    I hope it helps.
     
  4. jirimotejlek

    jirimotejlek

    Joined:
    Nov 8, 2016
    Posts:
    7
    Thank you very much, that is exactly what I needed to know. I have implemented the "MyCustomClass" based on DrupalBaseData and it works really well. This asset is really great.

    I have one more question, I'm performing periodical update/creation of nodes on Drupal and am battling with weird issues with UnityWebRequest (Mac) - it stops working within 15 minutes since it starts creating nodes, the only solution is to restart the game. I have tried plenty of things but nothing works.

    I posted a question on another forum - ArgumentNullException Appear Randomly

    https : // forum.unity.com/threads/argumentnullexception-appear-randomly-in-unitywebrequest.541629/
    (added spaces, this forum doesn't allow me to send links here)

    and according to a Unity Technologies moderator:
    All symptoms of reusing UnityWebRequest after it has been disposed. It's a bug in your code.
    If you call Dispose() method on UWR or put UWR object in a using block (which calls Dispose() uppon leaving the block), you have to make sure you don't use that same UWR object. You should create a new one.


    Do you think it's possible that UnityWebRequest is used after it was disposed of in DrupalAPI? I'm not instantiating UnityWebRequest anywhere myself.

    Since I'm not instantiating UnityWebRequest anywhere myself
     
  5. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    733
    I sent you a fix through a private message.
     
  6. jirimotejlek

    jirimotejlek

    Joined:
    Nov 8, 2016
    Posts:
    7
    Thank you! It works as expected, you've provided really great support.
     
unityunity