This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »



Overview

The following operations allow you to work with users. Click an operation name to see details on how to use it. 

For a sample proxy service that illustrates how to work with users, see Sample configuration.

OperationDescription
11Working with Users in SurveyMonkeyRetrieves details of a user

Operation details

This section provides details on each of the operations.

Retrieving details of the user 

The getUserDetails operation returns the logged-in user's basic information. 

getUserDetails
<surveymonkey.getUserDetails/>
Sample request
Following is a sample REST request that can be handled by the getUserDetails operation.
Sample Request for getUserDetails
{
"apiUrl":"https://api.surveymonkey.net",
"accessToken":"UFHR1aBDl2QjFoOzyDhoj91aM1Q3Atp-HtOvcI8kBk.HIBEdrGLtGKLnbSmHGcE-O0lYLVuaD910D6MPZv.iRH5X7-jBQeLsb6WS1eya7gc=",
"apiKey":"u366xz3zv6s9jje5mm3495fk"
}
Related SurveyMonkey documentation

https://developer.surveymonkey.com/mashery/get_user_details  

Sample configuration 

Following is a sample proxy service that illustrates how to connect to SurveyMonkey with the init operation and use the getUserDetails operation. The sample request for this proxy can be found in getUserDetails sample request. You can use this sample as a template for using other operations in this category. 

 

 As a best practice, create a separate sequence for handling the response payload for errors. In the following sample, this sequence is "faultHandlerSeq".


Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="SurveyMonkey_getUserDetails" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
  <target>
   <inSequence onError="faultHandlerSeq">
      <property name="apiUrl" expression="json-eval($.apiUrl)"/>
      <property name="accessToken" expression="json-eval($.accessToken)"/>
      <property name="apiKey" expression="json-eval($.apiKey)"/>
      <surveymonkey.init>
        <accessToken>{$ctx:accessToken}</accessToken>
	    <apiUrl>{$ctx:apiUrl}</apiUrl>
		<apiKey>{$ctx:apiKey}</apiKey>
      </surveymonkey.init>
      <surveymonkey.getUserDetails/> 
	  <property name="responseStatus" expression="json-eval($.status)"/>
         <filter source="$axis2:HTTP_SC" regex="^[^2][0-9][0-9]">
            <then>
               <switch source="$axis2:HTTP_SC">
                  <case regex="401">
                     <property name="ERROR_CODE" value="600401"/>
                     <property name="ERROR_MESSAGE" value="Unauthorized"/>
                  </case>
                  <case regex="404">
                     <property name="ERROR_CODE" value="600404"/>
                     <property name="ERROR_MESSAGE" value="Not Found"/>
                  </case>
                  <case regex="400">
                     <property name="ERROR_CODE" value="600400"/>
                     <property name="ERROR_MESSAGE" value="Bad Request"/>
                  </case>
				  <case regex="403">
                     <property name="ERROR_CODE" value="600403"/>
                     <property name="ERROR_MESSAGE" value="Forbidden."/>
                  </case>
                  <case regex="500">
                     <property name="ERROR_CODE" value="600500"/>
                     <property name="ERROR_MESSAGE" value="Internal Server Error"/>
                  </case>
               </switch>
			   <property name="messageType" value="application/json" scope="axis2"/>
               <sequence key="faultHandlerSeq"/>
            </then>
            <else>
               <filter xpath="get-property('responseStatus') != 0">
                  <then>
					 <switch source="get-property('responseStatus')">
						<case regex="1">
							<property name="HTTP_SC" value="401" scope="axis2"></property>
							<property name="ERROR_CODE" value="600401"/>
							<property name="ERROR_MESSAGE" value="Unauthorized"/>
						</case>
						<case regex="2">
							<property name="HTTP_SC" value="403" scope="axis2"></property>
							<property name="ERROR_CODE" value="600403"/>
							<property name="ERROR_MESSAGE" value="Forbidden."/>
						</case>
						<case regex="3">
							<property name="HTTP_SC" value="400" scope="axis2"></property>
							<property name="ERROR_CODE" value="600400"/>
							<property name="ERROR_MESSAGE" value="Bad Request"/>
						</case>
						<case regex="4">
							<property name="HTTP_SC" value="403" scope="axis2"></property>
							<property name="ERROR_CODE" value="600403"/>
							<property name="ERROR_MESSAGE" value="Unknown User"/>
						</case>
						<case regex="5">
							<property name="HTTP_SC" value="500" scope="axis2"></property>
							<property name="ERROR_CODE" value="600500"/>
							<property name="ERROR_MESSAGE" value="Internal Server Error"/>
						</case>
					 </switch>
					 <property name="error_description" expression="json-eval($.errmsg)"/>
					 <property name="messageType" value="application/json" scope="axis2"/>
					 <sequence key="faultHandlerSeq"/>
                  </then>
               </filter>
            </else>
         </filter>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
      <faultSequence>
		 <property name="ERROR_CODE" value="600500"/>
		 <property name="ERROR_MESSAGE" value="Internal Server Error"/>
		 <property name="messageType" value="application/json" scope="axis2"/>
         <sequence key="faultHandlerSeq"/>
      </faultSequence>
   </target>
   <description/>
</proxy>


  • No labels