Jump to content

Lorenzo Sampietro

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Hi, thank you for your reply. It seems Accept image/webp or */* (see screenshot) Do you mean I must work on HTML source?
  2. Good morning, I've opened the same question to stack overflow: https://stackoverflow.com/questions/67299714/rad-studio-10-4-2-rad-server-and-duplicate-enpoints-image-or-text I'm following this David Intersimone's video tutorial about RAD Server: https://www.youtube.com/watch?v=eCyTiDq_jBY&list=WL&index=6&t=2723s At minute 43 he explain how to setup multiple access types using EndpoinProduce directive. You can find the same example at page 142 of "The Complete Guide To RAD Server". I exactly copy the example but it still now working. Here you can find the code: unit Unit1; // EMS Resource Module interface uses System.SysUtils, System.Classes, System.JSON, EMS.Services, EMS.ResourceAPI, EMS.ResourceTypes; type [ResourceName('AcceptTypes')] TAcceptTypesResource1 = class(TDataModule) published [ResourceSuffix ('*')] [EndpointProduce ('application/xml')] // [EndPointResponseDetails(200, 'Ok', TAPIDoc.TPrimitiveType.spObject, TAPIDoc.TPrimitiveFormat.None, '', '')] // [EndPointResponseDetails(404, 'Not Found', TAPIDoc.TPrimitiveType.spNull, TAPIDoc.TPrimitiveFormat.None, '', '')] procedure GetText(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); [ResourceSuffix ('*')] [EndpointProduce ('image/jpeg')] // [EndPointRequestSummary('Tests', 'ListItems', 'Retrieves list of items', 'application/json', '')] // [EndPointResponseDetails(200, 'Ok', TAPIDoc.TPrimitiveType.spObject, TAPIDoc.TPrimitiveFormat.None, '', '')] procedure GetImage(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); end; implementation {%CLASSGROUP 'System.Classes.TPersistent'} {$R *.dfm} procedure TAcceptTypesResource1.GetImage(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); var fs: TFileStream; begin fs := TFileStream.Create('c:\RADServer\page\content.jpeg', fmOpenRead); AResponse.Body.SetStream(fs, 'image/jpeg', True); end; procedure TAcceptTypesResource1.GetText(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); var fs: TFileStream; begin fs := TFileStream.Create('c:\RADServer\page\content.txt', fmOpenRead); AResponse.Body.SetStream(fs, 'text/plain', True); end; procedure Register; begin RegisterResource(TypeInfo(TAcceptTypesResource1)); end; initialization Register; end. The page HTML that invoke the software is: <html> <head> <title>a page for rad server</title> </head> <building> <h1>a page</h1> <p>an image below</p> <img src="/AcceptTypes/test.jpeg"> <p>&nbsp;</p> <h1>some more</h1> <iframe src="/AcceptTypes/test.txt"> </building> </html> When I run the software RAD Server returns this error: {"Thread":2216,"Error":{"Type":"HTTP","Code":"500","Reason":"Error","Error":"Resource error","Description":"Duplicate endpoints: GetText, GetImage. Each endpoint must have an unique HTTP method, URL or produce / consume types"}} It seems it don't recognize the endpoints. Do you have any idea? thank you
×