Remote Webservice call - post process / missing params in outgoing request

i 've set up a remote web service which needs a couple of parameters.
1 header for basic auth, a couple of params which are always the same, and 2 params which are specific to each request i am sending.
I even did a swagger service definition.
It works like a charm.

The result is xml .

My idea was to process the result inside a post process script to convert it to json.

But inside the scripts area i can not add a custom script to the service.
Is this possibility not implemented or i’am missing something?
(ok after upgrade to 2.1 this is solved)

My second idea to was to create a custom Scripting Service and call the remote web service inside the script.

var myparams = event.request.parameters ;
var_dump(myparams);
var result = platform.api.get(“mart/search”, myparams );
return result;

The output of the log file:
output of var dump:
object(Object)#2120450790 (2) {
[“searchterm”] =>
string(6) “winkel”
[“supplier”] =>
string(4) “flex”
}

Outbound HTTP request: GET: https://ws.mart.net/services/catalog/search?buyer=xxxxxx&format=xml&language=de&results=300&portal=xxxx

myparams (searchterm and supplier ) are not added to the outbound Get request.

What i am doing wrong?

Thank you very much in advance for help,

Michael

Ps.
Bitnamistack on centos
Admin Application Version: 2.0.6
DreamFactory Version: 2.0.4

According to my recent discussion with support engineer pre and post processing scripts are not available to Remote Web Service or Custom Scripting Services.

@mharvey I was mistaken on that front.
Had a follow up conversation with the dev team, and pre/post process scripts ARE supported for remote web services.
But you have to provide swagger definitions for your service, as the scripting engine uses these to know what verbs and resources to provide scripting support to.

Thank you very much for your answers.

After upgrading to version 2.1and providing a swagger definition i’ve was able to add a script to my service.

I noticed, you’ve implemented xml to json conversion into the system (inside the api docs a xml response is shown in json format).

could you please be so kind to give some hints of the functions / libs already available inside the scripts?

Also confirmed was able to add scripts after adding swagger docs. Agreed. Docs on this would also be great.

I have an issue with api_docs choking on the uploaded docs which is another issue I think.

Actually, I’d like to know specifically what is required in the swagger docs to enable the creation of pre/post scripts. My docs show up and seem to work okay, but I don’t get the option in the scripts window. My swagger js looks like this:

	{
		"basePath": "https://www.gocanvas.com/apiv2",
		"produces": [
			"application/xml"
		],
		"consumes": [
			"application/json",
			"application/xml",
			"application/xml",
			"application/json"
		],
		"apis": [
			{
				"path": "/submissions.xml",
				"description": "retrieve submissions by submission_guid",
				"operations": [
					{
						"nickname": "retrieve submission",
						"method": "GET",
						"parameters": [
							{
								"name": "id",
								"description": "submission id passed by notifier",
								"type": "string",
								"paramType": "query",
								"required": false
							},
							{
								"name": "password",
								"description": "canvas password",
								"type": "string",
								"paramType": "query",
								"required": true
							},
							{
								"name": "username",
								"description": "canvas username",
								"type": "string",
								"paramType": "query",
								"required": true
							}
						],
						"responseMessages": [
							{
								"code": "200",
								"message": "OK"
							}
						]
					}
				]
			}
		],
		"models": {}
	}

I am not sure, but i think you need DF version 2.1,

then your api should be available under :
Scripts -> Process Event Scripts -> your API ->… your api.get.post_process.

After upgrading to 2.1 you even have to change your swagger definition.

At the beginning you need:

“swagger”: “2.0”,
“info”: {
“title”: “Your API”,
“description”: “xxxxxxxxxxx”,
“version”: “1.0.0”
},

Thanks. I am on 2.1, and did change the service description to 2.o format, but the issue was the missing paths:. Now I see the pre and post options under script.

Example Swagger definitions for custom script: https://blog.dreamfactory.com/put-some-swagger-in-your-dreamfactory-custom-scripting-services