Remote Web Service and Headers

Hello guys,
Merry christmas and all.

Those days, I am playing now with the Remote Web Service api type.
And I think that with DSP 1.8.2 the Headers defined in the Request parameters (with the param type as “header”) are not passed to the called web service !

That is to say,
I need the user to give a parameter when he will be calling my api (which is a remote web service api)
This number should be passed as a header when calling the remote web service…

{
       "name": "If-Unmodified-Since-Version",
       "description": "Item's current version number",
        "required": true,
        "type": "integer",
         paramType": "header"
}

But this does not work.
What it does, it is that it is calling MY DSP api with this parameter in the header but I don’t think that it this header is forwarded to the remote web service…

Request Headers:
...
If-Unmodified-Since-Version:13
...

Is there a way to forward this parameter as a header to the remote web service ?

I am really looking forward to your answers because I really need this :confused:

Anyway, I still love your product :smile:

Thanks for the love, @stadja. :blush:

All headers should be passed on through the DSP to the remote endpoint. Can you provide steps to replicate this problem and more details on your configuration? I’d like to test your same situation in my environment.

OK,
it’s gonna be a bit tricky for you to test it.
But anyway.

I created a service:

  • type: Remote Web Service
  • endpoint: https://api.zotero.org
  • I added some parameters (if you need I’ll send them to you by PM)

In My service definition I have this api definition:

{
          "parameters": [
            {
              "description": "",
              "paramType": "path",
              "required": true,
              "type": "string",
              "allowMultiple": false,
              "name": "users_or_groups",
              "enum": [
                "users",
                "groups"
              ]
            },
            {
              "defaultValue": "",
              "paramType": "path",
              "required": true,
              "type": "string",
              "allowMultiple": false,
              "name": "elementId"
            },
            {
              "description": "A specific Item in the library.",
              "paramType": "path",
              "required": true,
              "type": "string",
              "allowMultiple": false,
              "name": "itemKey"
            },
            {
              "name": "If-Unmodified-Since-Version",
              "description": "Item's current version number",
              "required": true,
              "type": "integer",
              "paramType": "header"
            }
          ],
          "nickname": "deleteItem",
          "responseMessages": [
            {
              "message": "No Content: The item was successfully updated.",
              "code": 204
            },
            {
              "message": "Conflict: The target library is locked.",
              "code": 409
            },
            {
              "message": "Precondition Failed: The item has changed since retrieval (i.e., the provided item version no longer matches).",
              "code": 412
            }
          ],
          "summary": "Deleting an item - Right now, this is not working",
          "method": "Delete"
        }
      ],
      "path": "/{users_or_groups}/{elementId}/items/{itemKey}"
    }

So.
When I call the Api via the swagger interface, I see that If-Unmodified-Since-Version is passed to the DSP call.
But the response I receive is “no If-Unmodified-Since-Version header”

I tried to put in my service definition a If-Unmodified-Since-Version header. And when I do that it works! But I can’t change it with the swagger interface.

Is there a way to make a query api parameter and to transform it in a header parameter when sent to the remote endpoint ? It might be another way to do it…

Anyway, you can try it here:
http://stadja.net:81/swagger/zotero.html#!/zotero/deleteItem

try with these parameters:

  • elementId: 2214605
  • itemKey: PMT2CUF8
  • If-Unmodified-Since-Version: 44

Watch the firebug response when you call it, you’ll see that he will consider not having received the If-Unmodified-Since-Version … BUT the header is sent to my dsp api.

If you want all my definitions (api key and all that I can give it to you by PM)

Bump ?
For me it´s à réal problem… :confused:

Sorry for the delay @stadja, we are reviewing this again at the beginning of the week.

@stadja I confirmed the client-sent headers are getting dropped at the DSP, upon adding additional headers from the service configuration. I am working on a fix for this and will send you commit so you can mod locally until 1.9 comes out.

Awesome!!!
Thank you very mutch :slight_smile:

@stadja Changed the admin app and the remote web service file in the platform library to allow a pass through option. These changes will be part of 1.9, but here are the commits.

https://github.com/dreamfactorysoftware/dsp-core/commit/36773ad58bc0a528fe4989a396d6eb6f24ace72c
https://github.com/dreamfactorysoftware/lib-php-common-platform/commit/1c5ad622d58b82172235e03daff71bd9661d09e3
(just the RemoteWebSvc.php)

Sorry for the delay - holidays, 1.9 and starting 2.0…lots to do. Let me know if this works for you.

2 Likes

Hey!
sorry for the delay!
I just updated my dsp and it does works !

If i had an additional header in the service,
i don’t put any value
i check the “Pass From Client”

And it works!
Super dooper… that’s a really cool thing.

Now I can make some authentification and all that stuff… I am happy with that :slight_smile:

BUT,
what I don’t think works well (or anyway, I couldn’t make it work), is to use the

Basic HTTP Authentication now supported per API call, using URL (i.e. https://user:password@server) or standard Basic Authentication header.

How is it supposed to work ?

https://github.com/dreamfactorysoftware/dsp-core/wiki/REST-API-Authentication

Let us know if you still can’t get it to work.

Thank You.
Well now, it’s time for the bug reporting!

So, I use various APIs and they need different type of Headers.

  • what is working:

The following header

If-Unmodified-Since-Version: 47

is working well: I can make it parametrable and passing it from the client, no problem.

  • what is NOT working:

I have to do a basic authentication to another api.
So If I send the following header:

Authorization: Basic Y293YWJvbzpQYXNzd29yZCA0IGNvd2Fib28=

it works if a put it in the “additional headers” and I give it a value, BUT if I let the value empty there and check “Pass From Client”, It acts as if I don’t pass anything from client when I do.

(maybe it is a problem with the uppercase A, or with the space in the value, I don’t know…)

Have you got any solution ?
This would really be totally awesome !

We have resolved passthrough of client-provided HTTP headers in the latest version of lib-common-php-platform.