title: IBM API Connect: Encoding and Decoding a URL
body: <p>I am using API Connect to construct an API to interface with some Teradata Database but I am not returning a result and can't debug it in API Connect for some reason. This query structure works for any other query we have except one that requires the encoding/decoding.</p>
  
  <p>This particular thing is driving me nuts. I know the query will return data using the the following parameter. However, since we have to pass it to the API we have to encode and decode the URL. But this code does not seem to initiate the way I think it does and will return nothing when queried in this way. Where am I making a mistake with the decoding?</p>
  
  <pre><code> //input = '%5Csome%5Cfile%Cpath%20here
   //this is an encoded input example just for reference
  
   var input = apim.getvariable('request.parameters');
  
   var parameter = decodeURI(input);
  
   var query1 = "SELECT * FROM 
   SOME_DBO.SOME_TABLE b where b.SOME_PARAMETER = '" + parameter
   + "';";
  
   var rowLimit1 =5000;
  
   var body1 = '{ "query":"' + query1 + '","rowLimit":' + rowLimit1 + '}';
  
   apim.setvariable('message.body', body1);
  
   apim.setvariable('message.headers.accept', 
  'application/vnd.com.teradata.rest-v1.0+json'); 
  </code></pre>