Needs work
Project:
Web service client
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 Aug 2012 at 18:52 UTC
Updated:
12 Apr 2013 at 13:11 UTC
Jump to comment: Most recent file
Comments
Comment #1
mrfelton commentedPatch to make required change.
Comment #2
klausiNot sure this is the right approach. You could also define a complex data type that holds all properties that you want in your request body.
You are casting to an array here - does that change the body contents if $operation['data'] is a string?
Comment #3
mrfelton commentedIn my case the API expects to receive 3 paramaters. 2 of them are complex data types, and one is an API key. eg.
Member and Credit Card are both complex datatypes that I have defined. To do what you are suggesting I would need to define one more complex data type, and make Member, Credit Card, and API key properties of that. But then what I would be passing into the remote function would be one paramater, and not the three that it expects.
No, it makes no difference. if you cast a string to an array, you just get an array with one element.
Comment #4
klausiWell, the current patch breaks the RESTWS test case in wsclient_examples. It adds an additional wrapper with the parameter name around the object. Request body:
But RESTWS expects only the inner structure:
So I still think you should create a data structure that holds the specific fields for your use case.
Comment #5
cknowles commentedI'm pretty new to Drupal but I've been trying to use this module for a few REST calls. First I realised the service I'm calling requires form data input but responds with XML data. I've sorted that using a HttpClientCompositeFormatter and HttpClientXMLFormatter from http_client inside a custom module. Then I realised I can't use the UI to customise the operation type so had to look into a custom module to do that too.
I've been trying to call a service based on a User account where I have to POST some data. Could you point me in the right direction of how to create the custom data structure you speak about above based on:
1) Some fixed parameters, preferably global to the service.
2) Fields from the user.
I know how to do this based on separate parameters to the operation - in fact that's what I did first using the UI module. But the module just adds those to the URL and doesn't execute a POST as required.
Comment #6
cknowles commentedFor anyone looking at this, I worked out this is possible at least with the service I'm using. What I did was this in my custom module set the type of the operation to POST but then just not add a "data" attribute to the operation. Instead I added parameters and the POST of the form data works fine (it's just URL not body based):