44
Views
7
Comments
Solved
Retrieve Address against Pin code from REST API
Application Type
Traditional Web

Dear All,

I am a beginner in OutSystems and I need your help. I have uploaded an Excel file using the Upload widget, and now I want to use a free API to retrieve addresses based on the pin codes in the file. When I enter a single pin code in a text input, the API works fine and displays the corresponding address in a table. However, I want to upload an Excel sheet with more than 100 pin codes. How can I retrieve the addresses for all of these pin codes using the API?

Please let me know if you need further clarification or information. Thank you in advance for your help.

Best regards,

Urvashi

2024-09-12 02-43-38
Deepsagar Dubey
Solution

HI @Urvashi Sharma 

You are using this API : https://api.postalpincode.in/pincode/{PINCODE} 

It's a GET api and accept only one Pin code, So you don't have any other option instead of call this API in loop,

You can find more details here

I hope it'll help you,

Thanks

Deep

2024-09-12 02-43-38
Deepsagar Dubey
Solution

Hi @Urvashi Sharma 

Create a server action with one Input parameter of List of Text type or integer type and one Output parameter of List of Result (any structure which hold your record),

Then pass all pin codes in this server action and loop on the list of pin codes and pass the current pin code to the rest API and append the rest api response in your output list.

I hope it'll help you,

Thanks

Deep 

UserImage.jpg
Urvashi Sharma

Hi @Deepsagar Dubey ,

Thank you so much for your kind support!!

It's working fine as I desired.

Regards,

Urvashi 

2024-09-12 02-43-38
Deepsagar Dubey
2023-04-06 11-24-23
Paulo Zacarias

Hi Urvashi, 

Even though this is possible, you will be doing 100 calls to the API (one for each pin code). Wouldn't it be better to have a method on the API that receives a list of pin codes and returns a list of pin code - addresses instead? The API has this method or can you build it?

Regards, 

PZ

UserImage.jpg
Urvashi Sharma

Hi Paula,

I use this API : https://api.postalpincode.in/pincode/{PINCODE} 

Add below is the logic build on button click in GetPincode add a variable to store a text input value


2024-09-12 02-43-38
Deepsagar Dubey
Solution

HI @Urvashi Sharma 

You are using this API : https://api.postalpincode.in/pincode/{PINCODE} 

It's a GET api and accept only one Pin code, So you don't have any other option instead of call this API in loop,

You can find more details here

I hope it'll help you,

Thanks

Deep

UserImage.jpg
Urvashi Sharma

Hi Deepsagar,


Can you help me how i can get result for all pincode in one attempt

2024-09-12 02-43-38
Deepsagar Dubey
Solution

Hi @Urvashi Sharma 

Create a server action with one Input parameter of List of Text type or integer type and one Output parameter of List of Result (any structure which hold your record),

Then pass all pin codes in this server action and loop on the list of pin codes and pass the current pin code to the rest API and append the rest api response in your output list.

I hope it'll help you,

Thanks

Deep 

UserImage.jpg
Urvashi Sharma

Hi @Deepsagar Dubey ,

Thank you so much for your kind support!!

It's working fine as I desired.

Regards,

Urvashi 

2024-09-12 02-43-38
Deepsagar Dubey
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.