php - Httpful post with urlencode -


I have a slightly larval app and I used to work with an external API - httpful REST customer added -

I was able to "speak" with the mailstore API Here is an example:

  Public Function GetEnvironmentInfo () {$ uri = 'https://bla.com:8474 / Api / invoke / GetEnvironmentInfo '; $ Response = Httpful :: post ($ uri) - & gt; With certification ('admin', 'password') - & gt; Send (); $ Errors = $ response- & gt; Body- & gt; Error; $ Version = $ response- & gt; Body- & gt; Results-> Edition; $ License = $ response- & gt; Body- & gt; Results-> License holder; DD ($ version. $ License. $ Errors); }   

that function works

You can find the following sentences in the API manual.

"When a function requires additional data, this data must be sent urlencoded.HTT header content-type: application / x-www-form-urlxode should be set."

For example, I want to set user password with the help of user password.

SetUserPassword

Set the mailstore user's password.

Argument name type description exampleID String Melstore Example unique ID in which this command is applied. User name string user name mailstore user

  public function SetUserPassword () {$ uri = 'bla.com:8474/api/invoke/SetUserPassword  

'; Edit header (array ('instanceID' => gtc: 'bla', 'username' = & gt; 'myuser') $ response = HTFF :: post ($ uri) -> credentials ('admin', 'password ') - & gt ;,' password '= & gt;' mypassword ')) - & gt; Sends the type (\ htpfile \ mem :: form m) - & gt; Send (); Dd ($ response & gt; body & gt; error); }

And here is the error response I received:

  object (stdClass) [142] public 'message' => String 'argument instanceID is missing.' (Length = 31) Public 'Description' = & gt; String 'System.Exception: argument instanceID is missing. Bei # Y3c #VGC # X3c (#ncb #tpc, # 8xe # I9f, string #GPf, name volocation # p5b, int 32 # joc) bi # u3c #VGC #slc (#lc #rmc, # 8xe # I 9f) '(length = 1 9 2)   

I have added example ID and other arguments to the header, but not the API logic or value Can get.

I think the problem is urlencode? Can you give me a hand?

Thank you!

You have passed the array in the adherer method ['content-type' = & gt; 'Application / x-www form- urlencoded']. The remaining parameters should be passed in the form of the post request body.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -