Questions tagged [ballerina-http]

Questions about working with the Ballerina HTTP Module (`ballerina/http`).

The Ballerina HTTP module provides APIs for connecting and interacting with HTTP and HTTP2 endpoints. It facilitates two types of network entry points as the client and listener.

11 questions
2
votes
1 answer

How to Add a Custom Field to an HTTP Return Record Type in Ballerina

I want to add a custom id field as part of the HTTP body. Here is my code that works, But this is not type-safe, since id is open to anydata and easy to make mistakes. import ballerina/http; service on new http:Listener(9090) { resource…
2
votes
1 answer

Unable to pass dynamic values to config records

I have a requirement to pass a JWT client assertion to the oauth2 client credentials grant config record. I'm passing the parameter as the optional parameter. But this parameter has to be generated each time the token endpoint is called for an…
Thishani Lucas
  • 550
  • 1
  • 3
  • 21
1
vote
0 answers

getting error trying to test service using a get request

I'm new to Ballerina and am encountering an error. I have made a service and am using Postman and the terminal using the curl command, but I keep getting this error: curl: (7) Failed to connect to localhost port 8080 after 0 ms: Connection…
1
vote
0 answers

How do I solve a "cannot resolve module 'ballerinax/kafka' " error in ballerina

I'm trying to import ballerinax/kafka so I can solve a kafka assignment but when I type it out, it gives me an error that says cannot resolve module 'ballerinax/kafka'
1
vote
1 answer

Ballerina - can we check response status code for a URL like www.google.com?

I am new to Ballerina, and i want to know if I can find the response status of any url. This is basically to check if the system is up or down.
Betty
  • 28
  • 4
1
vote
0 answers

How to access and process json array sent to a service resource in Ballerina

I have a POST resource and I want to pass a JSON array as the request payload. @http:ResourceConfig { methods: ["POST"], path: "/news-articles/validatetest", cors: { allowOrigins: ["*"], allowHeaders: ["Authorization,…
Samitha Chathuranga
  • 1,689
  • 5
  • 30
  • 57
0
votes
1 answer

Mapping json to Ballerina record

{ "ID": "2bdaad2e-e6f4-49d1-b737-e0276d8ccc03", "name": "simple-config", "metadata": {}, "secret_type": "Opaque", "environment_id": "b1402013-b080-488d-858b-dadcb07a551a", "data": null } Above…
0
votes
1 answer

Passing Query Parameters in Ballerina HTTP Client

In Ballerina HTTP client, we can send requests using the following syntax: Album[] albums = check albumClient->/albums; But if we need to send query parameters with this request like this: albums?genre=pop How can we do this with the above syntax?
ThisaruG
  • 3,222
  • 7
  • 38
  • 60
0
votes
1 answer

Adding extra auth parameter to client credentials grant type in Ballerina?

I need to send a request like the one below. curl --request POST --url https://dev-jlsubxnitkpok2tw.au.auth0.com/oauth/token --header 'content-type: application/json' \ --data…
Krv Perera
  • 119
  • 2
  • 15
0
votes
2 answers

Set encoding in ballerina.io for HTTP GET response (ISO-8859-1 )

I download several CSV files via HTTP endpoints and write them into a database. This works. But I noticed that parts of my response are wrongly encoded. Example: var response =…
Martin
  • 65
  • 3