C# deserialization from Java(android) header - c#

I am working on some android project, so i need to send hashtags to the server by Header info.
So this is the server code they have for getting the hashtags.
if (Request.Headers.Contains("hashtags"))
newPost.HashTags = new System.Web.Script.Serialization.JavaScriptSerializer()
.Deserialize<List<string>> (Request.Headers.GetValues("hashtags").First());
and i really don't know how to send ArrayList in java side to a single parametar by Headers parametar.
conn.setRequestProperty("hashtags", "");
I guess i need to serialize somehow the list and send it as string?
Please if anyone knows anything share with me, i really appreciate it!

I found a solution
You need to post in this format
["element1","element2","element3"]
in simple String format.
Hope this helps!

Related

How to Open Default browser and target an element?

Hi all I have done some google work and not come up with a great deal apart from using the browser within a From which I dont want to do.
Has anybody some sample code or a good resource that is detailed enough to get me on my way plesae
So for example
Process.Start("https://www.google.com")
and target the search element with a string and click search.
Using the default browser
Please help me...
Doing something like this would work:
string mySearchQuery = "this is a search example";
Process.Start("https://www.google.com/search?q=" + Uri.EscapeDataString(mySearchQuery));
If I'm understanding you correctly, this would use the default browser set in windows, then the query is just passed in as a GET request (that's the ?q variable).

JSOn object not deserializing properly in wcf webservice side

I am working on iOS project and sending the Json string to backend through wcf webservice, Its working successfully for many users but for some users backend getting incomplete json string.
Code for generating Json string
NSData *data = [NSJSONSerialization dataWithJSONObject:EmployeeDetails options:0 error:nil];
NSString *JsonString = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
And Attaching the json string with request by below code
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
EmployeeDetails is NSMutableDictionary with employee details.
And
Here is successful Json string deserialized from BackEnd
{"FirstName":"Donald","LastCBPaymentType":6,"AcceptEmail":true,"CellPhone":"321-300-6874","Position":"3","CarrierNum":"4","EmpNum":"96874"}
And Incomplete Json string
{"FirstName":"roset","LastCBPaymentType":6,"AcceptEmail":true,"CellPhone":"321-300-6874","Position":"3","CarrierNum":"4","EmpNum":"98799
The incomplete json string occuring in backend for some user.
Any one can help to solve this issue ?
Well, I'd say TomSwift is on the right track... It's apparent that the broken JSON is simply missing "} from the end of the string. That does indeed look like something being sanitised by a regex...
You really should find the source of the problem; But for a quick and dirty fix while you figure it out, you could just run your own regex on the JSON you receive and if it doesn't end with a "}, just add it... First do something like: '/"[0-9]+$/' (to check if there is an open numeric string at the end, if there is, you close it by adding " ) then check if '/}$/' (if } is the last char, if it isn't: add it).
Remember, the above would only be a temporary fix (as it is somewhat heavy and not really that pretty), but I could imagine myself being forced to do something like this, simply because of time constraints. If the issue is actually coming from within the API, you could tell the creators about it and use something like that fix above while they fixed it.
PS. If anyone does choose to use a fix like the above, please please please, for the love of all that you hold holy, leave a comment in the code explaining why you did it (as opposed to telling us what you did...).
I had a similar problem in PHP/CodeIgniter recently and the problem was that the JSON was being "sanitized" via some overly ambitious regular expressions before it arrived to my handler. Perhaps there's some similar sanitization that happens in WCF?
Things I would try:
Using Charles Proxy to confirm that the request (POST?) is actually sending the full body as you expect.
Try Content-Type application/json instead.

Unexpected json result while calling the surveymonkey api

When calling the surveymonkey api I'm using
{\"survey_id\":\"47625442\"," +"\"fields[]\":\"['url']\"}"
as the json data the server needs to complete my request. while it is returning the data it is required it is not returning the additional URL i believe i am requesting. Does anyone know why this wouldn't give me this back?
EDIT https://developer.surveymonkey.com/mashery/get_collector_list this is the call im trying to make if this helps
As was pointed out in the comments: Your JSON formatting is off, so the API doesn't understand that you're asking for the URL.
For an understanding of what's going on, take a look at the example request in the link you provided; note the format of the fields section.
Try again, this time with:
{"survey_id": "47625442", "fields": ["url"]}
...which with the escapes will look like this....
{\"survey_id\": \"47625442\", \"fields\":[ \"url\" ]}"

No Json payload returned with api request [duplicate]

When calling the surveymonkey api I'm using
{\"survey_id\":\"47625442\"," +"\"fields[]\":\"['url']\"}"
as the json data the server needs to complete my request. while it is returning the data it is required it is not returning the additional URL i believe i am requesting. Does anyone know why this wouldn't give me this back?
EDIT https://developer.surveymonkey.com/mashery/get_collector_list this is the call im trying to make if this helps
As was pointed out in the comments: Your JSON formatting is off, so the API doesn't understand that you're asking for the URL.
For an understanding of what's going on, take a look at the example request in the link you provided; note the format of the fields section.
Try again, this time with:
{"survey_id": "47625442", "fields": ["url"]}
...which with the escapes will look like this....
{\"survey_id\": \"47625442\", \"fields\":[ \"url\" ]}"

How to GET reCAPTCHA picture address?

This is my idea:
I get this address from source, for example: http://api.recaptcha.net/challenge?k=6Lc_Wb0SAAAAAPpDWSnsxg7rFxSJT46Wmic3Ximb
Then I get "challenge" from this site, for example: challenge : '03AHJ_VuumDpsD-dz-rSeL_Vyd5fUqHMJLNtlpiyaEq0RzDhsaNTWTydaOcYk5cdRX55C6VyaojWJwCa6T6PF8LF4Io5NUC09Kj0HRNczh9tJXBsrx26BcfBtrwvPabvbR_SnJXdmc9YS2L76PqI9EdtfXPhhCV9V2jw'
Then I get address of picture, for example: http://www.google.com/recaptcha/api/image?c=03AHJ_VuumDpsD-dz-rSeL_Vyd5fUqHMJLNtlpiyaEq0RzDhsaNTWTydaOcYk5cdRX55C6VyaojWJwCa6T6PF8LF4Io5NUC09Kj0HRNczh9tJXBsrx26BcfBtrwvPabvbR_SnJXdmc9YS2L76PqI9EdtfXPhhCV9V2jw
But there is a problem - pic is other than I have to write. Can you tell me how I can get oryginal address?
If the image you get doesn't match up with the one that you have to type then I'm guessing you aren't passing the same challenge code to the verification method of the api as to the image part.
It would help if you could paste a bit of code.
If you look at the non-javascript API call output for how it actually gets fetched without all the javascript getting in the way, there wouldn't appear to be a reason your strategy would give the wrong image.
http://www.google.com/recaptcha/api/noscript?k=6Lc_Wb0SAAAAAPpDWSnsxg7rFxSJT46Wmic3Ximb
Mike got the point you need to pass recaptcha_challenge_field=03AHJ_VuumDpsD-dz-rSeL_Vyd5fUqHMJLNtlpiyaEq0RzDhsaNTWTydaOcYk5cdRX55C6VyaojWJwCa6T6PF8LF4Io5NUC09Kj0HRNczh9tJXBsrx26BcfBtrwvPabvbR_SnJXdmc9YS2L76PqI9EdtfXPhhCV9V2jw

Categories

Resources