Closed hellokirk closed 7 years ago
If you want DreamFactory to pass on specific headers to the remote HTTP service you can set that in the Config tab for the remote service. From the Services tab select the HTTP service and go to the Config tab. Under the 'Headers' section add a new entry and enter the name of the header and check 'Pass From Client'. Select all verbs and save the config.
So from a scripting service how would I pass a variable value into a header key? I tried setting up an 'Authorization' key in the config (tried both a null value and a placeholder value), but the value I pass in from my scripting service still seems to be ignored.
See the section on adding HTTP headers. Let me know if it helps.
http://wiki.dreamfactory.com/DreamFactory/Features/Scripting#Resources_Available_To_A_Script
If you want the header sent on to the remote service you have to set up the header in the service config as previously mentioned.
$url = 'http://example.com/my_api';
$payload = json_decode("{\"name\":\"test\"}", true);
$options = [];
$options['headers'] = [];
$options['headers']['Content-Type'] = 'application/json';
$options['parameters'] = [];
$options['parameters']['api_key'] = 'my_api_key';
$api = $platform['api'];
$post = $api->post;
$result = $post($url, $payload, $options);
var_dump($result);
Thank you, but unfortunately, it does not help. That is the example I followed to get to my issue in the first place. I have the 'Authorization' header key set in the config and it works fine when run from the api docs or from another script without trying to change the key; however, I still can't get that header value to change when using the platform api resource.
I've tried a couple different methods to invalidate the value that's in the config:
$options['headers']['Authorization'] = 'bogus';
cURL options can include HTTP headers using CURLOPT_HTTPHEADER, but it's recommended to use options.headers for V8js or $options['headers'] for PHP to send headers as shown above.
Despite that warning, I've also tried things like:
$options[CURLOPT_HTTPHEADER][] = 'Authorization: bogus';
Ok got it. Looking into this with engineering team. Will report back soon.
Lee fixed this in develop branch of df-rws. I used requestbin to verify that headers were passed through properly when calling HTTP service from a script.
I'm calling a Remote Service, HTTP Service from another PHP Scripting service like this:
The documentation shows it here, but I don't think those headers values are being passed through correctly.