Thursday, 24 July 2025

How to Mock APIs 10x Faster Using AI Chatbots

In our latest tutorial, we create a dynamic mock that returns different responses based on the day of the week. What typically takes 20 minutes of documentation diving, AI completes helps us complete in under 2 minutes.


Quick Tips for Success

Choose the Right Model
  • Paid models (Claude Opus 4, ChatGPT 4.5) = first-try success
  • Free models = expect 2-3 iterations

Write Better Prompts

  • Be specific about your requirements
  • Describe expected behavior clearly

Beyond Basic Mocks

  • Use AI for complex troubleshooting
  • Validate your debugging approach
  • Discover diagnostic steps you might have missed

Get Started Today

We've built custom AI assistants specifically for Traffic Parrot users. Access them at trafficparrot.com/ai.

⚠️ Security reminder: Always remove sensitive data before sharing with AI.



Sunday, 20 July 2025

Traffic Parrot 5.54.2 released, what's new?

We have just released version 5.54.2. Here is a list of the changes that came with the release:

Features

  • Added Composite scenario support for HTTP virtual services, allowing you to combine mappings from multiple scenarios into a single active scenario
  • Added URL rewriting support during HTTP recording via the trafficparrot.http.recording.rewrite.regex property to automatically transform URLs in response bodies
  • Added RequestToPdf response transformer for generating PDF files from request bodies in test environments
  • Added support for Brotli compression decoding during HTTP recording

Fixes

  • Fixed a UI mapping list rendering issue seen on some browsers
  • Fixed tooltip display issues in the web interface
  • Library upgrades to fix OWASP issues

Changes

  • Upgraded bundled JRE from 21.0.6 to 21.0.7

Monday, 19 May 2025

Traffic Parrot 5.53.1 released, what's new?

We have just released version 5.53.1. Here is a list of the changes that came with the release:

Features

  • Added new properties to performance profile settings:
    trafficparrot.virtualservice.httpRequestLoggingDisabled=true
    trafficparrot.virtualservice.accessLogsEnabled=false
    trafficparrot.virtualservice.handlebars.maxCacheEntries=10000

Thursday, 15 May 2025

Setting custom domain for Traffic Parrot HTTP mocks

 "I want to use an abc.local.excample.com domain instead of localhost to bypass the cors errors while recording. I used mkcert to generate the keys. Should this command work?
./start.sh trafficparrot.gui.https.port=21000 trafficparrot.virtualservice.https.port=21001 -Djavax.net.ssl.keyStore=~/pem/keystore.p12 
-Djavax.net.ssl.keyStorePassword=password12345678 -Djavax.net.ssl.keyStoreType=PKCS12 -Djavax.net.ssl.keyAlias=trafficparrot- Staff Engineer working for a US university.

The solution to this issue is described in the documentation in the section "Change the HTTPS server certificate." https://trafficparrot.com/documentation/5.51.x/user_guide.html

If you connect to Traffic Parrot via HTTPS it will return a self-signed certificate.

If you would like Traffic Parrot to use a different certificate for its HTTPS virtual service you can override the PrivateKeyEntry called trafficparrot in trafficparrot-x.y.z/certificates/trafficparrot-keystore.jks. The password to the JKS keystore is trafficparrot.

Tuesday, 22 April 2025

Traffic Parrot 5.53.0 released, what's new?

We have just released version 5.53.0. Here is a list of the changes that came with the release:

Features

  • Added searchable dropdown to scenario selection in the UI for better usability

Fixes

  • Library upgrades to fix OWASP issues

Changes

  • Increased the minimum Java runtime requirement from Java 8 to Java 17. We will continue to support Java 8 for all customers that have not yet upgraded.
  • Upgraded Jetty server from v9 to v12

Thursday, 17 April 2025

How do I set up an OPTIONS request in Traffic Parrot?

 "UI is making an OPTIONS request but the mock doesn’t seem to be returning the right headers resulting in CORS error. I tried changing port , URL, nothing helped, only the same Allow, Server response headers were being sent back." - Staff Engineer working for a US university.

By default, trafficparrot.properties has a flag set:
trafficparrot.http.optionsResponse.enabled=true

This tells Traffic Parrot to return a default automatic OPTIONS response with the "allow" header set only, for any defined mapping.


If you set the flag to false:

trafficparrot.http.optionsResponse.enabled=false

It will allow you to define your own custom OPTIONS response instead.

Monday, 10 March 2025

Can Traffic Parrot return binary files in responses?

 "Can an HTTP response in Traffic Parrot contain a binary file?" - software developer working for an e-commerce company.

Yes.

The simplest way to create a mock in Traffic Parrot that returns a binary file in the response is to create that mock by doing a recording. That assumes you have a real service that you can record.

If you don't have a real service that returns the binary file in the response, you can create a mapping manually. To do that:

  1. Create a file in trafficparrot-x.y.z/mappings directory called, for example mapping-dummy-file.json
  2. The mapping-dummy-file.json should contain the following (notice the reference to body-dummy-file.pdf): 
    {
      "id" : "5d6a8f32-914c-4b67-ae15-f2c9d7b3e091",
      "name" : "mapping-dummy-file.json",
      "request" : {
        "url" : "/dummy.pdf",
        "method" : "GET"
      },
      "response" : {
        "status" : 200,
        "bodyFileName" : "body-dummy-file.pdf",
        "headers" : {
          "Content-type" : "application/pdf"
        }
      }
    }
  3. Create the binary response body file body-dummy-file.pdf in trafficparrot-x.y.z/__files. You can use any PDF file just make sure the filename is specified in the mapping json file in bodyFileName attribute
  4. Now if you visit http://localhost:8081/dummy.pdf then a PDF binary file will be returned. 

Monday, 24 February 2025

Traffic Parrot 5.52.0 released, what's new?

We have just released version 5.52.0. Here is a list of the changes that came with the release:

Features

  • Import OpenAPI files from the openapi configuration directory on startup
  • Enable in trafficparrot.properties by setting:
    trafficparrot.openapi.import.on.startup=true

Fixes

  • Library upgrades to fix OWASP issues

Changes

  • Upgraded bundled JRE from 8u402 to 21.0.6
  • OpenAPI imports performed via the UI will override the previous import rather than duplicating mappings
  • Downgraded to WireMock 2 request matchers and Handlebars response templating helpers due to performance issues with WireMock 3

Tuesday, 18 February 2025

How to Mock Twilio SDK Calls With Traffic Parrot

Current flow

RabbitMQ -> SpringBoot + Twilio SDK -> Twilio API

Desired flow with Traffic Parrot

RabbitMQ -> SpringBoot + Twilio SDK -> Traffic Parrot -> Twilio API

Details

  • Using Twilio REST API v2010
  • Endpoint: /Accounts/{account_sid}/Messages.json
  • OpenAPI spec: https://raw.githubusercontent.com/twilio/twilio-oai/main/spec/json/twilio_api_v2010.json

Question

How can we intercept and mock Twilio SDK calls using Traffic Parrot since the SDK doesn't accept a configurable URL?

Answer

Setup steps:

  1. Update your code to send requests to Traffic Parrot instead of real Twilio APIs, see sample code below
  2. Run Traffic Parrot on port 8081
  3. Configure recorder to forward requests to api.twilio.com
  4. Record sample responses from Twilio
  5. Switch recorder to replay mode
  6. Use the mock responses in your tests
// 1. Create a custom HTTP client that redirects Twilio requests to Traffic Parrot
public class TrafficParrotHttpClient extends NetworkHttpClient {
    private static final String TWILIO_API = "https://api.twilio.com";
    private static final String TRAFFIC_PARROT = "http://localhost:8081";
    
    @Override
    public Response makeRequest(Request request) {
        // Rewrite URL to point to Traffic Parrot
        String rewrittenUrl = request.getUrl().replace(TWILIO_API, TRAFFIC_PARROT);
        
        // Create new request with rewritten URL while preserving auth and other properties
        Request rewrittenRequest = new Request(request.getMethod(), rewrittenUrl)
            .setAuth(request.getUsername(), request.getPassword())
            .setHeaders(request.getHeaders());
            
        return super.makeRequest(rewrittenRequest);
    }
}

// 2. Configure Twilio client to use custom HTTP client
TwilioRestClient client = new TwilioRestClient.Builder("YOUR_ACCOUNT_SID", "YOUR_AUTH_TOKEN")
    .httpClient(new TrafficParrotHttpClient())
    .build();

// 3. Set as default client
Twilio.setRestClient(client);

// 4. Use Twilio SDK normally - calls will be redirected to Traffic Parrot
Message message = Message.creator(
    new PhoneNumber("+1555555555"),
    new PhoneNumber("+1555555556"), 
    "Hello from Traffic Parrot!")
    .create();

Monday, 13 January 2025

Retrieving Filenames from Binary HTTP Requests in Traffic Parrot

 We got a question recently from one of our prospects.

"When a file is sent as binary data rather than form-data, is it possible to retrieve the filename in a response in Traffic Parrot?" - Software Developer working for a French company

If you also have this issue, please send the trafficparrot.log to support@trafficparrot.com so we can see how your file is being sent to Traffic Parrot in the HTTP request.

There are many ways a filename could be included in a HTTP request, and it is hard to guess which one your company uses.

For example, here is one way you could extract it from a header for a binary request:

{{ regex request.headers.Content-Disposition 'filename=\"([^\"]+)\"' 'g' }}

Here is how you could test it:

curl -X POST http://localhost:8081/hello -H "Content-Type: application/octet-stream" -H "Content-Disposition: attachment; filename=\"helloworld.png\"" --data-binary @helloworld.png -v

Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1:8081...
* Connected to localhost (127.0.0.1) port 8081 (#0)
> POST /hello HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Type: application/octet-stream
> Content-Disposition: attachment; filename="helloworld.png"
> Content-Length: 70509
>
* We are completely uploaded and fine
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Matched-Stub-Id: 8c4695d4-f94e-4ba8-9793-ee5dcbfba6b5
< Matched-Stub-Name: hello-8c4695d4-f94e-4ba8-9793-ee5dcbfba6b5.json
< Vary: Accept-Encoding, User-Agent
< Content-Length: 41
< Server: Jetty(9.4.56.v20240826)
<

Request contains a file: helloworld.png



Saturday, 11 January 2025

Traffic Parrot 5.51.1 released, what's new?

We have just released version 5.51.1. Here is a list of the changes that came with the release:

Features

Changes

Monday, 30 December 2024

Solving QA Environment Availability Issues with Partial Pass-Through JMS IBM MQ Mocks

Testing teams often face common QA environment challenges:

  • Environment downtime
  • Intermittent errors from backend systems
  • Test data setup takes weeks
  • Teams conflict over shared test data
  • Limited test scenarios
While the long-term solution involves stabilizing shared environments and implementing testing pyramids, here's a quick fix using Traffic Parrot's partial pass-through mocking capabilities.



We implemented this solution for a mobile onboarding application connecting to IBM MQ middleware. By creating mock queues alongside production queues, we enabled:

  • Simultaneous mocked and real responses based on test data
  • Automated test data setup and reset
  • Extended test coverage for previously unavailable scenarios
  • Reduced environment dependencies
 Key Implementation Steps:
  • Create additional mock queues
  • Reconfigure client to use mock queues
  • Set up pass-through mocks in Traffic Parrot

The beauty of this approach? You maintain real system integration while having the flexibility to mock specific scenarios. For example, we successfully mocked unsupported mobile service types while passing through all other requests to the actual backend.

Want to try it yourself? Check out Traffic Parrot's demo applications on GitHub, which have step-by-step implementation guides.

Friday, 27 December 2024

Partial passthrough and proxy HTTP mocks

Are you struggling with unstable QA environments, conflicting test data, or time-consuming setups?

Meet partial HTTP mocks using Traffic Parrot.

Here's how it works: Traffic Parrot acts as a smart proxy between your app and backend systems. Regular requests go to the real system, while special test cases use predefined mock data.

In our demo, a financial app gets real stock prices for Apple and Google but uses mock data for test scenarios like unlisted companies.

The result? Always available environments, stable responses, and quick test data setup - all without changing your core systems.

Tuesday, 10 December 2024

Using Handlebars for Date Comparisons in Response Logic in Traffic Parrot

 We received a question recently from one of our prospects.

"I wanted to know about the advanced usage of dynamic rules. How do I add scripting for my response logic? I need some date comparisons for calculating some fields values, is it possible to with scripting or handlebars?" - Software Developer working for a gaming company.

You can add scripting to your response login with scripts or handlebars. Here is the documentation on how to do that: https://trafficparrot.com/documentation/5.50.x/dynamic.html  

Handbars should be enough for this simple case of comparing dates.

For example, you can add this into your response body like on the screenshot displayed below:

{{#if (gt (date (parseDate request.query.SomeDate format='dd-MM-yyyy')) (date (now)))}}
Response if the defined date is after now
{{else}}
Response if the defined date is not after now
{{/if}}

This code compares SomeDate request query parameter with today's date and returns a different response based on that comparison. 

Here is an example result:

support@support-pcs:/optf/git$ curl http://localhost:8081/hello?SomeDate=01-01-2024
Response if the defined date is not after now
support@support-pcs:/optf/git$ curl http://localhost:8081/hello?SomeDate=01-01-2025
Response if the defined date is after now


Friday, 6 December 2024

How to configure Traffic Parrot log level at runtime in Docker

We got a question from one of our customers about how to configure the log level at runtime when using Traffic Parrot in Docker.
How to pass environment variables to Docker
The Dockerfile CMD command can be modified to accept environment variables as follows:
ENV GUI_HTTP_PORT=8080
ENV VS_HTTP_PORT=8081
CMD exec ./start-foreground.sh \
    trafficparrot.gui.http.port=$GUI_HTTP_PORT \
    trafficparrot.virtualservice.http.port=$VS_HTTP_PORT
How to set the logging level dynamically with Docker environment variables
First the Dockerfile can be configured with an environment variable:
ENV LOG_LEVEL=ERROR
This can be then be configured for use:
  • trafficparrotserver.log4j.properties can be configured with:
    log4j.rootLogger=${LOG_LEVEL},file,stdout
    And the Dockerfile with:
    CMD exec ./start-foreground.sh -DLOG_LEVEL=$LOG_LEVEL
  • trafficparrotserver.log4j2.xml can be configured with:
    <Root level="${env:LOG_LEVEL}">
  • trafficparrotserver.logback.xml can be configured with:
    <root level="${LOG_LEVEL}">