Where to add "Headers" in Send-HTTP-Request in TIBCO BW 6.5? - tibco

I have created a queue (MyQueueName) in Azure ServiceBus. To send message on that queue I create an Authorization token with a Java class and I pass it in the 'Headers' in POSTMAN
I am doing a POST operation and I am hitting this URL (https://AzureSampleNamespace.servicebus.windows.net/MyQueueName/messages) in POSTMAN.
Header contain 3 name/value pair i.e:-
1) Authorization :- My Auth Token
2) Host :- AzureSampleNamespace.servicebus.windows.net
3) Content-Type :- text/plain
In the 'Body' of POSTMAN I am just passing a sample raw text as input. When hitting via POSTMAN I am successfully able to send message on my queue and got a '201 created' ( response body is empty)
Now to do the same POST via TIBCO BW 6.5, I created a Timer activity followed by 'Send-HTTP-Request' activity.
In the Send-HTTP-Request, I created its HTTP Client which has Host as 'AzureSampleNamespace.servicebus.windows.net' and Port as '443' [as I am doing HTTPS call].
In the 'Input' tab configuration are:-
1) Method :- 'POST'
2)RequestURI :- '/MyQueueName/messages'
3)PostData:- 'Hello this is a sample text'
Now I created 3 Dynamic Headers, whose name and value contains this :- (Authorization , Host , Content-Type).
When I am running my process.bwp , it goes till Send-HTTP-Request and waits there only. It does not complete the process and is not able to send the message on my queue.
Can anyone please help me in resolving this?
Thanks,
Rudra

You can add http headers in the InputEditor tab of the SendHTTPRequest.
On the right side of the configuration you can scroll to Select Header Type Configuration > Create New Type Definition > Ok
Now +ABC sign will be visible where you can add the header elements you need to invoke a request.
Please note the requests which work with POSTMAN may not work with BW if there is a connectivity issue with outbound LB. Send HTTP Request Input Editor

Related

Nifi invoke http how to get a value and add as Header during post data

I have a NiFi flow which needs to post the data to some other server, before posting it needs to fetch a value from my internal server or Nifi Distributed cache.
And add that Value in to Http header before posting the data, also update when gets particular error code 401.
Below is the flow I am trying, all green processor I could do but stuck at getting the value and adding in invoke http header . What are other process I can make us to achieve this .
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.9.0/org.apache.nifi.processors.standard.InvokeHTTP/
according to documentation on http code 401 InvikeHTTP routes file to No Retry relation.
also flow file should contain some response attributes including invokehttp.status.code
so, you could use RouteOnAttribute processor to redirect flow file to your external token processor only when invokehttp.status.code=401.

How to pass from and body as parameters in Twilio SMS webhook URL

I have a Twilio SMS number configured to send a request to a WebServer via a Webhook URL. What I am trying to understand is can I pass the 'from' phone number and 'SMS body' as parameters in the Webhook URL?
For example:
https://myserver/v1/sms?phoneNo='FROM'&message='MSG'
I understand I can extract this information from the Body on the server but this would require additional coding, testing, deployment etc... on the web server.
Thanks.
Keep the URL as https://myserver/v1/sms (Twilio will add the parameters for you when it makes the request)
To the right of the webhook url field, change in the drop-down from HTTP POST to HTTP GET
Save
With this configuration, Twilio will send the parameters with its request as URL query parameters.
The names for the two parameters mentioned in your question are
From (The phone number that sent the message) and
Body (The text body of the message.).
Other parameters are: MessageSid, SmsSid, AccountSid, MessagingServiceSid, To, NumMedia
You can read more here: https://www.twilio.com/docs/sms/twiml#twilios-request-to-your-application
If you'd like to have your own names for the GET parameters
then, probably the easiest would be to use Twilio Studio with a HTTP REQUEST widget and configure the phone number with Studio Flow instead of Webhook.
The HTTP REQUEST will let you make a GET request and add your own parameters to it.
For the values you would use {{trigger.message.From}} for your phoneNo and {{trigger.message.Body}} for your message.
You can read more about Twilio Studio's widgets here: https://www.twilio.com/docs/studio/widget-library#http-request

Jmeter header manager reuse

Im using Jmeter to write some load tests on an API secured by oAuth.
I want to be able to reuse the header manager once the bearer token has been produced from the access token call.
However when I try to move the header manager out side of the http request the call is no longer authorised. I think its because it can no longer get the bearer token.
For Post Request, when i put the header manager outside it no longer works, it only works when I put it under the request as I have done for User get request, Delete request and Put request.
How do I make the header manager reusable and therefore only manage one header manager?
Thank you.
{"fault":{"faultstring":"Invalid access token","detail":{"errorcode":"oauth.v2.InvalidAccessToken"}}}
My expectation is that this is due to clash with the HTTP Authorization Manager
Both are Configuration Elements and both obey JMeter Scoping rules
When you move HTTP Header Manager outside the HTTP Request sampler it might be the case that Authorization Header comes from the HTTP Authorization Manager
You can check which exact header value is being sent using Request -> Request Headers tab of the View Results Tree listener
Given you manually create Authorization header for your request I believe if you disable or delete the HTTP Authorization Manager your test should start working as expected as you basically don't need it.

how to fix 404 not able to find Path in Rest API jmeter

I am getting below error while testing Rest APi in jmeter
"status":404,"error":"Not Found","message":"No message available","path":"/api/get_user_by_id/"}
I have /api/get_user_by_id/ which i have added in Path and also i have added parameters Name as user and id as userid. When i run i get below response
And in Request i get /api/get_user_by_id/?user=userid instead it should be
/api/get_user_by_id/userid
How can i solve this ?
Instead of putting your userid into "Send Parameters With the Request" section just add it to "Path" of the HTTP Request sampler
You might also need to add a HTTP Header Manager and configure it to send Content-Type header with the value of application/json

How to authenticate user when testing REST API using Jmeter

I am trying to make a script to test REST services using Jmeter.
Till now I was using Chrome’s Advanced REST Client.
My authentication request was GET and it was something like this in Advanced REST:
https://username:password#URL:portnumber
its a GET request
Now when I am using Jmeter. I tried following ways:
I added HTTP Authorization Manager and mentioned Base URL and Username/password inside it.
When I am trying to do a request then its showing me “Unauthorized”
I also tried to login using normal https request but no success.
When accessed manually, a authorization popup window appears and username and password is submitted inside this window.
Please suggest me a way for how to login using Jmeter.
Few suggestions:
Most likely you have mismatch in URL you're trying hit and the one, specified in HTTP Authorization Manager, double check it.
Add View Results Tree listener and make sure that the header like:
Authorization: Basic xxxxxxxxxxxx=
is being sent along with the request and compare it with the one, sent by the real browser.
Try switching "Implementation" of your HTTP Request samplers to HttpClient3.1, the easiest way of doing this is using HTTP Request Defaults
And finally, you can use HTTP Header Manager to send the relevant header, it's name should be Authorization and value Basic and username:password encoded in Base64. There is base64Encode function available via JMeter Plugins.

Resources