SFRestRequest Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | SFRestRequest.h |
Other Methods
method
The HTTP method of the request. See SFRestMethod.
@property (nonatomic, assign, readwrite) SFRestMethod methodDeclared In
SFRestRequest.h
networkServiceType
The HTTP method of the request. See SFRestMethod.
@property (nonatomic, assign, readwrite) SFSDKNetworkServiceType networkServiceTypeDeclared In
SFRestRequest.h
serviceHostType
The type of service host for the request (e.g. login or instance).
@property (nonatomic, assign, readwrite) SFSDKRestServiceHostType serviceHostTypeDeclared In
SFRestRequest.h
baseURL
The base URL of the request, to be prepended to the value of the path property.
By default, this will be the API URL associated with the current user’s account.
One use would be when in a community setting and you want to send a request against the base API URL.
@property (nullable, nonatomic, strong, readwrite) NSString *baseURLDeclared In
SFRestRequest.h
path
The path of the request or the full URL to be used. If a full URL is passed in, the endpoint ceases to matter. For instance, “” (empty string), “v22.0/recent”, “v22.0/query”. Note that the path doesn’t have to start with a ‘/’. For instance, passing “v22.0/recent” is the same as passing “/v22.0/recent”.
@property (nonnull, nonatomic, strong, readwrite) NSString *pathDiscussion
Warning: Do not pass URL encoded query parameters in the path. Use the queryParams property instead.
Declared In
SFRestRequest.h
parseResponse
Used to specify if the response should be parsed. YES by default.
@property (nonatomic, assign) BOOL parseResponseDeclared In
SFRestRequest.h
customHeaders
Dictionary of any custom HTTP headers you wish to add to your request. You can also use
setHeaderValue:forHeaderName: to add headers to this property.
@property (nullable, nonatomic, strong, readwrite) NSMutableDictionary<NSString*NSString*> *customHeadersDeclared In
SFRestRequest.h
endpoint
Typically kSFDefaultRestEndpoint but you may use eg custom Apex endpoints
@property (nonnull, nonatomic, strong, readwrite) NSString *endpointDeclared In
SFRestRequest.h
timeoutInterval
Assigns the timeout interval allowed for this request.
@property (nonatomic, assign, readwrite) NSTimeInterval timeoutIntervalDeclared In
SFRestRequest.h
– prepareRequestForSend:
Prepares the request before sending it out.
- (nullable NSURLRequest *)prepareRequestForSend:(nonnull SFUserAccount *)userParameters
user |
User account. |
|---|
Return Value
NSURLRequest instance.
Declared In
SFRestRequest.h
– setHeaderValue:forHeaderName:
Sets the value for the specified HTTP header.
- (void)setHeaderValue:(nullable NSString *)value forHeaderName:(NSString *)nameParameters
value |
The header value. If value is |
|---|---|
name |
The name of the HTTP header to set. |
Declared In
SFRestRequest.h
– addPostFileData:paramName:fileName:mimeType:params:
Add file to upload
- (void)addPostFileData:(NSData *)fileData paramName:(NSString *)paramName fileName:(NSString *)fileName mimeType:(NSString *)mimeType params:(nullable NSDictionary *)paramsParameters
fileData |
Value of this POST parameter |
|---|---|
paramName |
Name of the POST parameter |
fileName |
Name of the file |
mimeType |
MIME type of the file |
params |
File properties (e.g. title, desc, contentSize) |
Declared In
SFRestRequest.h
– setCustomRequestBodyString:contentType:
Sets a custom request body based on an NSString representation.
- (void)setCustomRequestBodyString:(NSString *)bodyString contentType:(NSString *)contentTypeParameters
bodyString |
The NSString object representing the request body. |
|---|---|
contentType |
The content type associated with this request. |
Declared In
SFRestRequest.h
– setCustomRequestBodyDictionary:contentType:
Sets a custom request body based on an NSDictionary representation.
- (void)setCustomRequestBodyDictionary:(NSDictionary *)bodyDictionary contentType:(NSString *)contentTypeParameters
bodyDictionary |
The NSDictionary object representing the request body. |
|---|---|
contentType |
The content type associated with this request. |
Declared In
SFRestRequest.h
– setCustomRequestBodyData:contentType:
Sets a custom request body based on an NSData representation.
- (void)setCustomRequestBodyData:(NSData *)bodyData contentType:(NSString *)contentTypeParameters
bodyData |
The NSData object representing the request body. |
|---|---|
contentType |
The content type associated with this request. |
Declared In
SFRestRequest.h
– setCustomRequestBodyStream:contentType:
Sets a custom request body based on an NSInputStream representation.
- (void)setCustomRequestBodyStream:(NSInputStream *( ^ ) ( void ))bodyStreamBlock contentType:(NSString *)contentTypeParameters
bodyStreamBlock |
The block that will return an NSInputStream object representing the request body. |
|---|---|
contentType |
The content type associated with this request. |
Declared In
SFRestRequest.h
+ isNetworkError:
Indicates whether the error code of the given error specifies a network error.
+ (BOOL)isNetworkError:(NSError *)errorParameters
error |
The error object to check |
|---|
Return Value
YES if the error code of the given error specifies a network error
Declared In
SFRestRequest.h
+ httpMethodFromSFRestMethod:
Return HTTP method as string for SFRestMethod
+ (NSString *)httpMethodFromSFRestMethod:(SFRestMethod)restMethodParameters
restMethod |
The SFRestMethod |
|---|
Return Value
the HTTP string for the given SFRestMethod
Declared In
SFRestRequest.h
+ sfRestMethodFromHTTPMethod:
- Return SFRestMethod from string
+ (SFRestMethod)sfRestMethodFromHTTPMethod:(NSString *)httpMethodParameters
httpMethod |
An HTTP method; for example, “get” or “post” |
|---|
Return Value
The SFRestMethod enumerator for the given HTTP method
Declared In
SFRestRequest.h
+ requestWithMethod:path:queryParams:
Creates an SFRestRequest object. See SFRestMethod. If you need to set body on the request, use one of the ‘setCustomRequestBody…’ methods to do so with the instance returned by this method.
+ (instancetype)requestWithMethod:(SFRestMethod)method path:(NSString *)path queryParams:(nullable NSDictionary<NSString*,id> *)queryParamsDeclared In
SFRestRequest.h
+ requestWithMethod:serviceHostType:path:queryParams:
Creates an SFRestRequest object. See SFRestMethod. If you need to set body on the request, use one of the ‘setCustomRequestBody…’ methods to do so with the instance returned by this method.
+ (instancetype)requestWithMethod:(SFRestMethod)method serviceHostType:(SFSDKRestServiceHostType)hostType path:(NSString *)path queryParams:(nullable NSDictionary<NSString*,id> *)queryParamsParameters
method |
the HTTP method |
|---|---|
hostType |
the type of service host for the request. |
path |
|
queryParams |
the parameters of the request (could be nil) |
Declared In
SFRestRequest.h
+ requestWithMethod:baseURL:path:queryParams:
Creates an SFRestRequest object. To set the body of the request, use one of the setCustomRequestBody... methods on the returned instance.
+ (instancetype)requestWithMethod:(SFRestMethod)method baseURL:(NSString *)baseURL path:(NSString *)path queryParams:(nullable NSDictionary<NSString*,id> *)queryParamsParameters
method |
HTTP method |
|---|---|
baseURL |
Request URL |
path |
Request path |
queryParams |
Parameters of the request (can be nil) |
See Also
Declared In
SFRestRequest.h
+ customUrlRequestWithMethod:baseURL:path:queryParams:
Creates an SFRestRequest object to be used with non-Salesforce endpoints. To set body on the request, use one of the ‘setCustomRequestBody…’ methods on the returned instance.
+ (instancetype)customUrlRequestWithMethod:(SFRestMethod)method baseURL:(NSString *)baseURL path:(NSString *)path queryParams:(nullable NSDictionary<NSString*,id> *)queryParamsParameters
method |
the HTTP method |
|---|---|
baseURL |
the request URL |
path |
|
queryParams |
the parameters of the request (could be nil) |
See Also
Declared In
SFRestRequest.h
+ customEndPointRequestWithMethod:endPoint:path:queryParams:
Creates an SFRestRequest object to be used with custom Salesforce endpoints. See SFRestMethod. If you need to set body on the request, use one of the ‘setCustomRequestBody…’ methods to do so with the instance returned by this method.
+ (instancetype)customEndPointRequestWithMethod:(SFRestMethod)method endPoint:(NSString *)endPoint path:(NSString *)path queryParams:(nullable NSDictionary<NSString*,id> *)queryParamsDeclared In
SFRestRequest.h
Extension Methods
requestBodyStreamBlock
@property (nullable, nonatomic, copy) NSInputStream *( ^ ) ( void ) requestBodyStreamBlock instrumentationDelegateInternal
@property (nullable, nonatomic, strong) id<SFRestRequestDelegate> instrumentationDelegateInternal+ restUrlForBaseUrl:serviceHostType:credentials:
+ (nonnull NSString *)restUrlForBaseUrl:(nullable NSString *)baseUrl serviceHostType:(SFSDKRestServiceHostType)hostType credentials:(nonnull SFOAuthCredentials *)credentials