How to use the DeployIt's namePattern parameter in the repository/query web-service - deployit

I’m trying to use the REST API provided by DeployIt (v3.9) to list all the packages available on a given project.
Thus, I use the GET /repository/query service
So, I’m calling this service with the following URL:
http://[server]/deployit/repository/query?namePattern=my-app&type=udm.DeploymentPackage
Unfortunately, I don’t get anything (just an empty list).
If I remove the namePattern from my URL, then I get a long list of all applications (not only the only I'm interested in).
So it appears that I don’t set correctly the namePattern attribute. In the documentation, they say:
a search pattern for the name. This is like the SQL "LIKE" pattern:
the character '%' represents any string of zero or more characters,
and the character '_' (underscore) represents any single character.
Any literal use of these two characters must be escaped with a
backslash ('\'). Consequently, any literal instance of a backslash
must also be escaped, resulting in a double backslash ('\').
So I tried the following URL:
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=my-app : empty list
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=%my-app%: error 400
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=%25my-app%25 (trying to escape the % character): empty list
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=Applications/my-app/2.0.0 (with a real version): error, character ‘/’ not allowed.
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=2.0.0 : I get the list of all applications deployed with a version 2.0.0 (including my my-app), but that's not what I'm looking for (I want all versions available on DeployIt for my-app).
So, what is the correct URL to retrieve the list of deployed applications?

I've solved my problem. In fact, the namePattern only applies to the last part of the Application name, i.e. the version.
Thus, I have to use the parent attribute to retrieve the list of my application:
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&parent=Applications%2Fmy-app&resultsPerPage=-1

Related

How to find JSON parse error in existing Ruby code

First let me say that while I am a programmer, Ruby is very new to me. I'm trying to fix an application created by another developer, but I cannot find the issue. When the code is run, I get the error below:
JSON::ParserError: unexpected token at '{
"account":"xxxxxxx",
"role":"3",
"email":"xxxx#xxxxxxxx.com",
"password":'xxxxxxxxxxxx',
"connect_host":"xxxxxxx.xxxxxxx.api.xxxxxxxx.com"
}
'
Account is numeric. Email is standard/no special characters. Password does have special characters, on of them being a double quote which is why it is wrapped in single quotes. Connect host is just an URL with alpha-numeric characters. I've Googled quite a bit but the results I've come up with dealt with people trying to escape certain characters. My hope is that another set of eyes can see what mine are missing.
Based on the JSON you've pasted in above the error is the usage of single quotes for the value of "password" which is 'xxxxxxxxxxxx'.
It needs to be in double quotes so change it to be:
"password":"xxxxxxxxxxxx",
If you control the code that sets the input go change that otherwise you will have to handle changing the single quote usage possibly through this answer (which is JS but demonstrates the concept), Parsing string as JSON with single quotes?

What is the correct syntax to fold a JSON string?

I am using Delphi 2009 to build up a string variable containing a simple JON string from values I get from a database. This results in a string of the form below (although the real string could be much longer)
{"alice#example.com": {"first":"Alice", "id": 2},"bob#example.com": {"first":"Bob", "id":1},"cath#example.com": {"first":"Cath", "id":3},"derek#example.com": {"first":"Derek", "id": 4}}
This string gets sent as a header called Recipient-Variables in an email to a company.
The instructions I have for sending the emails to the company say
Note The value of the “Recipient-Variables” header should be
valid JSON string, otherwise we won’t be able to parse it. If
your “Recipient-Variables” header exceeds 998 characters,
you should use folding to spread the variables over multiple lines.
I have looked at these SO posts to try to understand what is meant by folding but cannot really understand the replies as they often seem to be referencing a particular editor.
notepad++ user defined regions with folding
Folding JSON at specific points
Can you customize code folding?
Please can somebody use my example to show me what syntax I should use or what characters I need to insert in my string to comply with the instruction and fold my JSON string, say in between the records for bob and cath?
(BTW I understand what is meant by folding when viewing JSON or other code in an editor but I don't understand how a simple JSON string needs to be formatted in order for the folding to happen at a specific place)
I finally found the answer myself so posting here to help others, just in case.
The answer is given in this document on rfc2822 standards, published in 2001 by the Network Working Group (P. Resnick, Editor)
https://www.rfc-editor.org/rfc/rfc2822#page-11
The document ...
specifies a syntax for text messages that are sent between computer
users, within the framework of "electronic mail" messages.
...and in particular describes how emails are constructed and in particular how to deal with long headers.
Section 2.2.3 talks about long header fields, > 998 characters, and says such headers need to be folded by inserting the CRLF characters followed immediately by some white space, eg a space character.
If the receiving server is following the same standards it will strip out the CRLF character before parsing the header, which will itself will include stripping space characters.
Though structured field bodies are defined in such a way that
folding can take place between many of the lexical tokens (and even
within some of the lexical tokens), folding SHOULD be limited to
placing the CRLF at higher-level syntactic breaks. For instance, if
a field body is defined as comma-separated values, it is recommended
that folding occur after the comma separating the structured items in
preference to other places where the field could be folded, even if
it is allowed elsewhere.
Later, in section 3.2.3 it explains how comments may be combined with folding white space.
So it seems that if generating the string through code, it is necessary to fold long header lines by detecting a higher level syntactic boundary, such as a comma, that is less than 988 characters from the start of the header (or the last fold point) and insert the three hex characters x0D0A20. This could be done after the header has been constructed or on the fly as it is generated.
As a follow up, I now notice that the Overbytes ICS component I am using (TSslSmtpCli) has a boolean property FoldHeaders so this might do all the work for me.

ResourceLoader returns empty strings

I am trying to use a *.resw file in my UWP app to store localized strings. I am loading these strings through ResourceLoader.GetString() and am placing them in a MessageDialog for presentation to the user, but no matter what I do the return value of GetString() is an empty (zero-length) string. I am following the SDK sample for localization, but am not getting the expected response.
The string I am trying to use is of the format InvalidAssemblyDialog.Message.
As it turns out this problem was due to my using dots in the keys for my strings in the *.resw file. Dots are reserved, and my usage of them was causing name-resolution errors. In the case of the example above, I changed it to InvalidAssemblyDialog_Message.
Here the documentation says "." characters should be replaced with "/" when resources are queried from code.
If a resource name is segmented (it contains "." characters), then replace dots with forward slash ("/") characters in the resource name. Property identifiers, for example, contain dots; so you'd need to do this substition in order to load one of those from code.

Detecting an invalid file name in WinJS

In .NET, I'd use System.IO.Path.GetInvalidFileNameChars to scan a string containing a filename to validate it does not contain invalid characters.
In WinJS, I can't find the equivalent to this function. Is there somewhere else that these characters could be retrieved? My code is building a string based on some metadata from a file, and I suspect that there may be characters present that will not work when creating a new file (imagine like the "title" of a Microsoft Word docx file for example, where the title could contain : and \ characters that wouldn't be valid file names). I'd like to remove or convert these invalid characters so that the file can be saved without user intervention.
Of course, I could just grab a list from .NET and hard code that, but that doesn't seem nearly as elegant.
My other thought was to expose the functionality from a C# component (and expose it as a WinRT component), but I'd rather not introduce a second run-time just for some simple functions like this if I could help it.
There doesn't seem to be a method in WinJS that does this.
Given the small number of special characters, I'd just hardcode those. To get the list, simply try to rename a file to file?.txt in Windows Explorer. It shows you the list of invalid characters:
\ / : * ? " < > |

How can I populate a query string variable to a text box which contains &,\ and $ in it

I have a variable like say A= drug & medicare $12/$15.
I need to assign it to a text box, but only 'drug' is posted the server. The rest of the data gets truncated.
this.textbox.text= request.querystring["A"].tostring();
The following is not valid for a="foo&bar$12":
http://example.com?a=foo&bar$12
The & symbol is a reserved character, it seperates query string variables. You will need to percent encode a value before sending them to that page.
Also & is a reserved character in HTML/XML. I suggest reading up on percent encoding and html encoding.
I believe you have problems with HTML entities. You need to read up on HTML escaping in your tool of choice. & cannot stand in HTML, since it begins an entity sequence - it needs to be replaced with &. Without specifying at least which toolchain you're using (as per #Richard's comment), we can't really suggest the best way to do it.
EDIT: Now that I reread your question, it seems A is not a variable but a query parameter :) Reading comprehension fail. Anyway, in this case a similar problem exists: & is not a valid character for a query parameter, and it needs URL escaping. Again, how exactly to do it is in the documentation for your toolchain, but in essence & will need to be replaced by %26. Plus sign is also not permitted (or rather it has another meaning); others are tolerated (but there are nicer ways to write them).
That looks more or less like ASP.NET pseudocode, so I'm going to diagnose your problem as the query string needing to be URL encoded. Key/value pairs in the query string are separated by an ampersand (&), and ASP.NET (along with other web platforms) automatically parse out the key value pairs for you.
In this case, the ampersand terminates the value of the "A=..." key/value pair. The problem will be solved if you can URL encode the link that brings the user into your page. If actually using ASP.NET, you can use the HttpUtility.UrlEncode() method for that:
string myValue = Server.UrlEncode("drug & medicare $12/$15");
You'll end up with this querystring instead: A=drug%20%26%20medicare%20%2412%2F%2415