Sending JSON through GET Method in Objective-C [duplicate] - objective-c

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
iPhone SDK Xcode 4.2 iOS 5- How do i send a json to url ? (POST and GET) [Resolved]
I have a seemingly easy question. I'm trying to send data from my iPad device to a server using JSON. The thing is, all tutorials I see about sending JSON to the server uses the POST method. My question is, is it possible to send JSON using the GET method? It will be really helpful if you can give me some pointers on how to do it. Thanks.

You should really convince your boss to either use JSON in the body of a POST or use GET Parameters in form of a GET:
http://www.example.com/?Argument1=Wert1&Argument2=Wert2
But the GET example will not be, as you can see, in form of a JSON. Indeed it would be possible to define a custom header where you put your json data in. But I would strongly advise against doing so because IMHO it is not the proper way

It's simple. JSON is actually sent via QueryString parameter. For instance to send a dictionary, use following format of URL
http://www.mywebsite.com/service.php?data={"key":"value", "key":"value"}
or an Array of Dictionaries as
http://www.mywebsite.com/service.php?data=[{"key":"value"}, {"key":"value"}]
Make sure you escape your url string properly

Related

Refference JSON schema from "define" API YAML file in Postman instead of creating a variable with actual JSON

I have an API in Postman that has defined JSON schemas for every request\response.
I also have a collection of tests that i use for testing this API.
But I don't know how to connect these two substances(things)
I have been searching for a solution for quite a while now and havent found an example set-up or a tutorial how? instead of creating a variable with actual schema in my test collection, I want to reuse already existing schema from API by $ref or some other link method.
This is my first question here, writing it just cause i haven't found a proper answer but functionality that i seek sounds really basic and logical.
Update from Valentin Despa:
"Please note that the API definition is written in a specification like Open API (or similar). It is not the same as the JSON schema which refers to the response body only."
So we can't validate response using that schema.

Can someone explain to me in what language this API code is written in?

I am supposed to create an API using this code. However I am not sure what language this is written in.
You are currently doing a curl using a shell:
See what is a shell(bash for example):
https://fr.wikipedia.org/wiki/Bourne-Again_shell
You are sending data using POST request, and for sending this data you are using a JSON format file.
I think you will have to create a webservice that accept JSON input
https://fr.wikipedia.org/wiki/JavaScript_Object_Notation
Please be more specific in your question, if it is not what you want.

How to send post request using Spookyjs with body parameter?

I want to send a post request with JSON body to a particular server using Spookyjs. How I do that please help into this?
If you are using spooky, then you are using nodeJS. Gather your informations (which I'm guessing you want to do) with spooky / casper, pass them back to nodeJS, parse your data and post it.

Getting file from .ashx with a jQuery Post

This question is a following from another question I asked - Passing client data to server to create Excel or CSV File.
I have a client page which builds a JSON object to send to the server, and I have server code which can parse that JSON object into an SQL command and end up with a dataset of required data.
I had originally been passing the JSON object to an .asmx web service which would return a JSON object containing my data. Now I want to go in a different direction and have the data returned as a .csv file.
I understand I can try to put my JSON object into a query string and call my .ashx page, but the JSON object could get large, so I'm trying to use the Request.Form of a POST.
My question, and lack of understanding, is in how to use jQuery to post to the .ashx page and have it return the .csv file to the client. If I navigate to the .ashx page directly (and modify the page to hard code the passed data), I get the .csv file returned to me no problem (i.e I get the prompt to open/save the file). If I make a POST to the .ashx file from jQuery and send my JSON object through, I get a response which contains the data in a string, rather than getting a .csv.
So, is there something I am missing, or am I just trying to achieve something that I can't or shouldn't be doing?
I'd thought about passing my JSON object to a .asmx web service which would store the JSON object into a database and return an ID, and then use window.location to browse to the .ashx with the ID as a query string parameter to then generate the .csv file, but I thought there might be a way to avoid that middle step and do it with the POST.
Sorry if this is a little rambling and disjointed. I'll be happy to clarify on any parts that may not make sense to anyone.
I am trying to do something similar as we speak.
Take a look at this question. It might help you.
How to: jQuery post to ashx file to force download of result?

yahoo answers API

I want to make use of the Yahoo answers API to extract the answers, I have got my consumer key which I guess is ncessary to get an access to the answers posted on the website. Can anybody guide me as to how can I make use of this API from my application.
OK, since you expanded on your question, I'll point you in the right direction at least:
You say you want to get the answers for a particular question.
That is achieved by making a GET request to the getQuestion method, which is documented at that link, so I won't repeat the instructions here.
This method requires you to know the Yahoo! Answers question_id, which you can either hard-code by taking it from the URL of a known question, or search for it using the other API methods such as questionSearch.
The response you get back will be XML, and the answers to the specific question will be in there - among other data such as the answerer's nickname, timestamps etc.
You'll need to parse this response to get the info you need.
If you need help making a GET request using Perl, I'd take a look at this question here first, but it's essentially:
use LWP::Simple;
$contents = get("http://YOUR_URL_HERE");