I tried to get Azure Usage details via nextLink which is shared by Azure. while i tried to make http request URISyntaxException is occured.
HttpClient httpclient = getHttpClient();
URIBuilder uriBuilder=new URIBuilder(url);
HttpGet httpGet = new HttpGet(uriBuilder.build());
HttpResponse httpResponse = httpclient.execute(httpGet);
This is the nextLink url:
"https://management.azure.com/subscriptions/78c50b17-61fd-40cc-819c-4953586c7850/providers/Microsoft.Consumption/usageDetails?api-version=2019-11-01&$filter=properties/usageStart eq '2020-07-1' and properties/usageEnd eq '2020-07-30' &metric=actualcost&$expand=properties/meterDetails,properties/additionalInfo&sessiontoken=15:785628&$skiptoken=827CDTHDWI07C46616C7365730&skiptokenver=v1&id=2d790-d675-45d-89j56-3989w06cca"
I think this is because of characters such as ?, & and ! in my URL. so I tried using:
URLEncoder.encode(myUrl, "UTF-8");
but after this, I faced protocol exception.
Am I missing something here?
question from:https://stackoverflow.com/questions/65950642/java-net-urisyntaxexception-illegal-character-in-query-at-index-177