Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to make this Web Api to work?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Divers
Thread ID:
01658678
Message ID:
01658795
Vues:
50
This message has been marked as a message which has helped to the initial question of the thread.
> services.Http.get("api/matrixTemplates/getAttributeValues/" + id + "/" + criteria);
>
>My question to you is - how exactly I need to code the above so it would work for any character criteria?

You shouldn't have to encode anything because the XHR request (ie. the Webrequest internal tot the browser) will automatically fix up the URL. If you want to be extra safe and don't rely on that behavior you can UrlEncode the parameterized value.

Either way passing a parameters object in the .get() call will never fill these parameters - you need to hard code those as you show above or by using `encodeURIComponent()` to encode the values.
services.Http.get("api/matrixTemplates/getAttributeValues/" + encodeURIComponent(id) + "/" + encodeURIComponent(criteria));
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform