107
Views
9
Comments
Gemini AI 1.5 Integration
Application Type
Reactive

Hi Guys,

I am trying to integrate with Gemini AI API, encountered with error "404 not found" in run time, tried many ways but not working. 

The Google AI is using Post REST API with key, and the request is multi-level of array in JSON format:

{"contents": [{"parts":[{"text": "Tell me a story about a storm"}]}]}

URL: https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=XXXXXXXXXXXXXXX

The test provides good return, but not in runtime.


2024-05-02 09-49-04
Murali Manoharan V
Champion

It's because your url contains ":". It's because of colon only

Add on before request to your api and add these second assignment as "CustomizedRequest.URLPath = Replace(CustomizedRequest.URLPath,"%3A",":")"

It will work afterwards.

Outsystems API call won't recognize ":" and take it as "%3A". So if you replace in On Before Request it will work

Regards

Murali

2024-02-23 01-51-15
StevenT

Hi Murali 

Thanks for your feedback.

Just would like to understand, in the Gemini AI API request has no URL.

The method has URL, do yo advise me to change the URL in the method ?


regards

 

2024-05-02 09-49-04
Murali Manoharan V
Champion

No. Create on Before request for whole API. See the screenshot for reference. 


On before request is used to customise api request before calling and on after response is used to customise api response after calling 

In on before request you need to change in URL as like I mentioned above

2024-05-02 09-49-04
Murali Manoharan V
Champion

Hi @HO MING STEVEN Tung 

Please use this documentation for on before request in rest api.

Simple Customizations - OutSystems 11 Documentation


Regards

Murali 

2024-05-02 09-49-04
Murali Manoharan V
Champion

Hi @HO MING STEVEN Tung 

I herein attached OML for your reference with the rest api call contains on before request. It will work for you.

Regards

Murali


Gemini.oml
2024-03-05 08-16-56
Kandreo Lanthreo

Please ensure to establish the necessary configurations before initiating the API request. Refer to the provided screenshot for guidance. The 'on before request' function serves to tailor the API request prior to execution, while the 'on after response' function allows customization of the API response post-execution.

In the 'on before request' phase, remember to modify the URL according to the instructions mentioned earlier. This step is crucial for ensuring accurate and customized API interactions.

UserImage.jpg
pramod jain


Request.URLPath = Replace(Request.URLPath,"%3A",":")


2024-02-23 01-51-15
StevenT

Thanks @pramod's feedback, I have been away for weeks, now am back.

I understand what you try to but it seems the GenerativelanguageGoogleapis structure of yours is different from my :

 My one : 

Yours : 

There is HTTPRequest structure in yours which you can change the URL, but my API dose not have this entity.

regards


2024-02-23 01-51-15
StevenT

Hi Pramod's, 

I did follow your idea to change the link before request, but the problem still the same : 


by the way the input request structure is very much different from the OnBeforeRequest but exactly the same as PostGeminipro. Would that affecting the result ?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.