Sequence contains more than one matching element on endpoint

Discussions relating to the REST API of Jiwa 7.

Sequence contains more than one matching element on endpoint

Postby sameermoin » Wed Apr 05, 2023 10:20 am

Hi Everyone,

I am getting an exception saying "{"ResponseStatus":{"ErrorCode":"Exception","Message":"Plugin 'Custom Plugin Name' caused an exception 'Sequence contains more than one matching element'"}}" on Jiwa "/Queries/SalesOrderList" endpoint.

if I disable that custom plugin and restart the API service then it works and if I re-enable the custom it stop working.

Endpoint: "http://localhost:8090/queries/SalesOrderList.json?Fields=InvoiceId&InvoiceNo=100505&apikey=7_G0vUX0tdRMkNhA2qW4Bm07E3yZEvCwHGNTaIQxDCs"
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

Re: Sequence contains more than one matching element on endp

Postby SBarnes » Wed Apr 05, 2023 10:35 am

Can you post the custom plugin?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Sequence contains more than one matching element on endp

Postby sameermoin » Wed Apr 05, 2023 10:44 am

No, I can't. It is a quite big plugin.
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

Re: Sequence contains more than one matching element on endp

Postby SBarnes » Wed Apr 05, 2023 10:59 am

Then I am not sure how you are expecting someone to work out what is wrong if Scott, Mike or I can't replicate the issue, could you provide a cut down plugin that exhibits the same problem?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Sequence contains more than one matching element on endp

Postby Mike.Sheen » Wed Apr 05, 2023 11:36 am

It could be a conflict introduced by your custom plugin. I'm not sure how things would behave if, for instance, your custom plugin added a route which conflicted with one we already have.

As you're trying the /Queries/SalesOrderList route - check to see if you are adding in your custom plugin the same route, or even a route with the same request class.

Failing that, start commenting out bits in your custom plugin, restart the API and test again until you can isolate the cause.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Sequence contains more than one matching element on endp

Postby SBarnes » Wed Apr 05, 2023 11:41 am

Also if you can replicate the problem on a machine with Visual Studio installed and can get the debugger up from the configure function with a System.Diagnostics.Debugger.Launch() statement you might find when you make the call Visual studio should jump to the line causing the exception.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Sequence contains more than one matching element on endp

Postby sameermoin » Wed Apr 05, 2023 6:36 pm

SBarnes wrote:Also if you can replicate the problem on a machine with Visual Studio installed and can get the debugger up from the configure function with a System.Diagnostics.Debugger.Launch() statement you might find when you make the call Visual studio should jump to the line causing the exception.



Not occurring locally. I commented complete Configure method even though the whole class but still occurring. I noticed it's occurring sometimes. Sometimes it returns the result.

I moved some parts of the plugin code into a new separate custom plugin also one system settings but, removed that from the main plugin
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

Re: Sequence contains more than one matching element on endp

Postby SBarnes » Wed Apr 05, 2023 6:41 pm

show-me-the-source-yoda.jpg
show-me-the-source-yoda.jpg (116.86 KiB) Viewed 2059 times

All I can suggest is you upload some version of the plugin
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Sequence contains more than one matching element on endp

Postby Mike.Sheen » Wed Apr 05, 2023 6:44 pm

Try turning on debug mode in the plugin system settings - this should give you the stack trace which might give you a clue.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Sequence contains more than one matching element on endp

Postby SBarnes » Wed Apr 05, 2023 6:59 pm

You could also try something like the below in your configure method which is from the documentation here


Code: Select all

    //Handle Exceptions occurring in Services:

    Apphost.ServiceExceptionHandlers.Add((httpReq, request, exception) => {
        //log your exceptions here

        //return null; //continue with default Error Handling

        //or return your own custom response
        return DtoUtils.CreateErrorResponse(request, exception);
    });

    //Handle Unhandled Exceptions occurring outside of Services
    //E.g. Exceptions during Request binding or in filters:
    AppHost.UncaughtExceptionHandlers.Add((req, res, operationName, ex) => {
         res.Write($"Error: {ex.GetType().Name}: {ex.Message}");
         res.EndRequest(skipHeaders: true);
    });


Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Next

Return to REST API

Who is online

Users browsing this forum: No registered users and 1 guest

cron