How to use custom request headers


#1

Dropsource does not currently provide the ability to set custom request headers inside the editor - however, depending on what data you need to pass in the header of a request, you may be able to achieve this via your Swagger/OpenAPI specification. One of our users recently asked if it would be possible to include two pieces of data in the header of a request - this is the guidance we gave them:

Include your two variables in the “securityDefinitions” in your Swagger and in each route that you need these variables to be sent for, you can set values for them inside Dropsource in the auth modal you’ll see in the API tab next to the API name (rather than in the parameters section of the request).

See the padlock button here:

You can set the values statically or using e.g. Device Variables if you want to set them dynamically while the app runs.

This example illustrates what it might look like in your Swagger:

“securityDefinitions”: {
“api_key”: {
“type”: “apiKey”,
“name”: “key”,
“in”: “header”
},
“app_id”: {
“type”: “apiKey”,
“name”: “appid”,
“in”: “header”
}
},
“security”: [{
“api_key”: [],
“app_id”: []
}]


Integrating Algolia - How Do I Send Headers Through Dropsource To The API?
#2

I have key value pairs such as:
SOA-SERVICE-NAME: FindingService
SOA-OPERATION-NAME: getHistograms

How do I use them or achieve this?


#3

Hi @dropuoso, have you tried using the method above? You would replace both occurrences of “api_key” and “app_id” with your two header names. Then in Dropsource you would use Device Variables to pass your values via the API auth control (create two variables, use Set Value actions to set your values, then select the Device Variables in the API tab). I can’t guarantee it will work but that is how you would try the method in this post.


#4

I have created the device variables ‘on application launch’ and then i make the call in the appropriate page of the app.

I keep getting a 403.

Has this method been tested?

Am i supposed to inject the variables (api keys) at a different point within the app?


#6

I’m think you add the keys/values at time of request so ensure you have all the values set to those keys before then. Maybe test that by adding some text labels on the page and showing the values stored in them on the page before you make the request. this is a way to test that you’re actually ready to make the request.

Also, Have you tested your call out in general outside of Dropsource. We recommend you test it out in POSTMAN 1st with the info you plan on sending from Dropsource. Just to make sure everything is setup properly outside of Dropsource (API & Backend) etc


#7

@wade all setup and working fine in Post Man using the same keys.

I did as you suggested and displayed the keys as text fields and they’re accurate and displaying.

But i keep getting a 403 error for invalid api key or application ID (the two keys that are saved).

What do i do from here?

How can i view the actual call being made to see what dropsource is sending out vs. what postman is sending out?


#8

Good question. Have a look at the Network Activity Log. When you run the app in the simulator, there’s a little switch for it. Turn it on and you’ll see a network analysis tool come on. As your app requests and receives data, you can tear into it to see what’s being pushed and pulled. Excellent way to validate a successful POSTMAN request/response against the 1 the app is sending/receiving.