Message Boards Message Boards

0
|
12574 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

how to use URLfetch for use with http post

I'm not very strong with http and urlfetch, but I'm trying to log in to my TD-Ameritrade account with urlfetch here is the API description: login post request How do I pass the parameters and how do call urlfetch? what is a content type http header?

POSTED BY: Kay Herbert
5 Replies

There maybe an issue with the documentation.

enter image description here

From local documentation "BodyData" is there and works. The link in the previous post does say "Wolfram Language"?

POSTED BY: Hans Michel

I have version 10.1, cannot find BodyData but it works while Body does not.

POSTED BY: Kay Herbert

The Options section of the Documentation located http://reference.wolfram.com/language/ref/URLFetch.html has "Body" as the option for the payload. I am using Mathematica version 10.0.2 and the local documentation has "BodyData" as the option for the payload. I would go with your local documentation ref/URLFetch. I did not find it per se though, the payload concept is part of most HTTP Request/Response client and server implementations.

POSTED BY: Hans Michel

Thanks, that worked! Exactly what I was looking for. Where did you find the BodyData option?

POSTED BY: Kay Herbert

Kay Herbert:

Try

URLFetch[
    "https://apis.tdameritrade.com/apps/300/LogIn?source=#sourceID#&version=#version number#",
    "Method" -> "Post",
    "Headers" -> {"Content-Type" -> "application/x-www-form-urlencoded"},
    "BodyData" -> "userid=#userid#&password=#password#&source=#sourceID#&version=#version number#\n\n",
    "Cookies" -> True,
    "VerifyPeer" -> True]

These variables are assigned by TD Ameritrade, hopefully you have them

  • userid=#userid#
  • password=#password#
  • source=#sourceID#
  • version=#version number#

Also assume you can fill in the proper Mathematica variables and re-work this starter code to work. So the #variable# should be replaced with the correct strings.

Hans

POSTED BY: Hans Michel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract