Jump to content









Photo

http_auth format

http sdk

  • Please log in to reply
2 replies to this topic

#1 Zambiot

Zambiot

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts
  • LocationAsia

Posted 06 April 2014 - 08:56 AM

I've got an api I'm trying to connect to that has basic http authentication.  In looking at the SDK documentation, it looks like there should be a means for handling authentication, but there isn't a model to show what should be in the map of 'http_auth'.  The following is a code example, but I'm getting an access denied error and it looks like the username is not getting through.  Any tips on this?

 

https://www.carriots...aries#basicHttp

 

// Send data to api
import com.carriots.sdk.utils.BasicHttp

httpHeader = [:]  
httpPayload = context.toString()

def Request = new BasicHttp()
Request.url = 'http://api.example.com/endpoint'
Request.verb = 'POST'
Request.headers = httpHeader
Request.payload = httpPayload
Request.http_auth =  ['myusername' : 'mypassword']
Request.send()

Thank you.



#2 Zambiot

Zambiot

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts
  • LocationAsia

Posted 06 April 2014 - 11:08 AM

OK, I figured this out after some experimenting and server log capturing.  

 

Request.http_auth =  ['user' : 'yourusername', 'password' : 'yourpassword']

Please update the docs.  



#3 jpastor

jpastor

    Development leader

  • Administrators
  • 178 posts

Posted 08 April 2014 - 04:32 PM

I'm glad your problem is resolved.

 

We will be more specific in the documentation.

 

 

Enjoy Carriots!







Also tagged with one or more of these keywords: http, sdk

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users