Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsRequestQueryString Limitation #10

Closed
SergeyBarskiy opened this issue Jan 12, 2018 · 7 comments
Closed

AsRequestQueryString Limitation #10

SergeyBarskiy opened this issue Jan 12, 2018 · 7 comments

Comments

@SergeyBarskiy
Copy link

SergeyBarskiy commented Jan 12, 2018

Hello, Dave.
We found an issue with AsRequestQueryString. If we do a spatial query on a complex shape, it will bust 65k limit of EscapeString in .NET Framework. Unfortunately, it switches to POST based on the serialized value, but it can never get that length based on this exception.

Do you have any suggestions or a fix?
Thank you.

@davetimmins
Copy link
Owner

Hi,

can you give me a bit more information please. Which line is failing? There is a test which has a complex shape that gets auto converted to POST so I thought that scenario should work. Also, if you're able to send me the query being run I could test it out.

Alternatively, if always running the operation as a POST would solve this for you you can do this by overriding the method in the gateway to invoke Post rather than Get

e.g.

public class ArcGISGateway : PortalGateway
{
    public ArcGISGateway(string root, ITokenProvider tokenProvider)
        : base(root, tokenProvider: tokenProvider)
    { }

    public override Task<QueryResponse<T>> Query<T>(Query queryOptions, CancellationToken ct = default(CancellationToken))
    {
        return Post<QueryResponse<T>, Query>(queryOptions, ct);
    }

@SergeyBarskiy
Copy link
Author

SergeyBarskiy commented Jan 12, 2018

Thanks for the quick reply, Dave. Here is the calls stack I should have included. The hard limit in System.UriHelper.EscapeString method is 65k. There is a complex parcel in our of our clients that has so many vertices that it blows up. They actually have a number of such parcels.

System.AggregateException: One or more errors occurred. ---> System.UriFormatException: Invalid URI: The Uri string is too long. at System.UriHelper.EscapeString(String input, Int32 start, Int32 end, Char[] dest, Int32& destPos, Boolean isUriString, Char force1, Char force2, Char rsvd) at System.Uri.EscapeDataString(String stringToEscape) at ArcGIS.ServiceModel.PortalGatewayBase.<>c__DisplayClass57_01.<AsRequestQueryString>b__0(String k) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.String.Join(String separator, IEnumerable`1 values) at ArcGIS.ServiceModel.PortalGatewayBase.AsRequestQueryString[T](ISerializer serializer, T objectToConvert) at ArcGIS.ServiceModel.PortalGatewayBase.Get[T,TRequest](TRequest requestObject, CancellationToken ct) at ArcGIS.ServiceModel.PortalGatewayBase.Query[T](Query queryOptions, CancellationToken ct)

@davetimmins
Copy link
Owner

Looks like you're using an old version of the old version of this project as that method is no longer used. Are you able to update your reference?

@SergeyBarskiy
Copy link
Author

It is indeed old version. I do see the same code in this repo in PortalGatewasBase: - https://github.com/davetimmins/Anywhere.ArcGIS/blob/66d51dca984693e38cff97668d5f77f6371aea2c/src/Anywhere.ArcGIS/PortalGatewayBase.cs. I must be missing something.
Thanks for your help as always. We will just override get in an inherited portal as you suggest and think about moving to this version in the future.

@davetimmins
Copy link
Owner

I had another look and it is still using EscapeDataString (sorry I had missed it before). Let me know if the POST workaround fixes it though. If not, can you share the service / feature that is that size or alternatively send me the JSON for the feature?

@davetimmins
Copy link
Owner

I was able to reproduce this and using POST does work, so the initial workaround I suggested should work for you. I'll put in a fix so that it'll work if GET is tried too.

@davetimmins
Copy link
Owner

Fixed in 1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants