@@ -103,7 +103,6 @@ function handleError(result: string): unknown {
103
103
return new Error ( 'Unexpected Error' ) ;
104
104
}
105
105
}
106
-
107
106
/**
108
107
* Retrieve a record from Dataverse
109
108
* @param apiConfig WebApiConfig object
@@ -119,14 +118,32 @@ export function retrieve(
119
118
submitRequest : RequestCallback ,
120
119
queryString ?: string ,
121
120
queryOptions ?: QueryOptions
121
+ ) : Promise < Entity > {
122
+ id = parseGuid ( id ) ;
123
+ return retrieveByKey ( apiConfig , entitySet , id , submitRequest , queryString , queryOptions ) ;
124
+ }
125
+ /**
126
+ * Retrieve a record from Dataverse
127
+ * @param apiConfig WebApiConfig object
128
+ * @param entitySet Type of entity to retrieve
129
+ * @param id Id of record to retrieve
130
+ * @param queryString OData query string parameters
131
+ * @param queryOptions Various query options for the query
132
+ */
133
+ export function retrieveByKey (
134
+ apiConfig : WebApiConfig ,
135
+ entitySet : string ,
136
+ key : string ,
137
+ submitRequest : RequestCallback ,
138
+ queryString ?: string ,
139
+ queryOptions ?: QueryOptions
122
140
) : Promise < Entity > {
123
141
if ( queryString != null && ! / ^ [ ? ] / . test ( queryString ) ) {
124
142
queryString = `?${ queryString } ` ;
125
143
}
126
144
127
- id = parseGuid ( id ) ;
128
145
129
- const query : string = queryString != null ? `${ entitySet } (${ id } )${ queryString } ` : `${ entitySet } (${ id } )` ;
146
+ const query : string = queryString != null ? `${ entitySet } (${ key } )${ queryString } ` : `${ entitySet } (${ key } )` ;
130
147
131
148
const config = {
132
149
method : 'GET' ,
0 commit comments