Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing Paramenter in Tron Request #30

Closed
iehsan77 opened this issue Mar 22, 2017 · 11 comments
Closed

Passing Paramenter in Tron Request #30

iehsan77 opened this issue Mar 22, 2017 · 11 comments
Labels

Comments

@iehsan77
Copy link

hi
with TRON - > how to use this URL (https://www.sampledomain/Device/GetFeature?token=f6b8a88b-6939-4bd6-a3f6-589020beb35d&PageNo&MQ==&PageSize=MTA=)

@DenTelezhkin
Copy link
Member

DenTelezhkin commented Mar 23, 2017

You should initialize TRON with baseURL "https://www.sampledomain", and then create a request with path "Device/GetFeature", and parameters ["token":"...", "MQ":"", "PageSize":"MTA"], something like that. Not sure about this URL being valid, since PageNo does not have a value, and MTA parameter does not have an & before it though.

@DenTelezhkin
Copy link
Member

Hmm, well first of all it seems your path is MvcSmartDevice/GetFeaturePearlQuery, and not GetCategories, like it says in code. Second, maybe inspect your API, it does not look like PageNo and PageSize are valid parameters, usually there are numbers, not stuff like MTA=.
Third, are you sure you need a POST request? Usually such kind of requests are GETs.

And i think for POST request by default parameters get encoded into HTTP body, not HTTP query, so if you really need POST request with parameters in query, you would need to change parameterEncoding property on APIRequest.

@iehsan77
Copy link
Author

iehsan77 commented Mar 23, 2017 via email

@DenTelezhkin
Copy link
Member

What are those symbols for? *

@iehsan77
Copy link
Author

iehsan77 commented Mar 23, 2017 via email

@popeyelau
Copy link

tron.headerBuilder = HeaderBuilder(defaultHeaders: [:])

@iehsan77
Copy link
Author

iehsan77 commented Mar 23, 2017 via email

@DenTelezhkin
Copy link
Member

@iehsan77 you wrote this:

and how I can  do this *"**parameters in the query"*

And i didn't understand, what * are about.

@DenTelezhkin
Copy link
Member

HeaderBuilder is used to encode headers for HTTP request, but in your URL it looks like you need to pass token in HTTP query, not headers. In that case you don't need to pass token to HeaderBuilder, but use parameters on APIRequest.

@reshadf
Copy link

reshadf commented Mar 29, 2017

You should build it up like this

let request: APIRequest<Model, Error> = tron.request("url")
request.parameters = ["token":token, "id": id]

@iehsan77
Copy link
Author

iehsan77 commented Mar 29, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants