Response mapping on web request - Patch

Hi,

I’m using the web request component to patch a record in a third party system. The response from the system is status “204” when successfull.

How can I map this response to a datasource. I have tried to do the same as i do in Get requests without any success.

Response:

The status code you’re trying map is not a part of the response data, but a HTTP status code of the web request. Successful responses give a 200-something response, and the rest of the action will continue to execute. However, if the request is unsuccessful, the web request would throw an exception (status code 400- or 500-something) and end the execution of the action. However, if you want the action to continue even though the web request fails, you may catch the exception using the Catch Exeption action node.

In your example, the response contains no data, i.e. there are no data to be mapped. If there were data you could map to a data object, the response would contain a rawData object.

Example from a response from Brreg:

{
	"requestConfig": {
		"url": "https://data.brreg.no/enhetsregisteret/api/enheter/919697199",
		"headers": {}
	},
	"responseData": {
		"status": 200,
		"statusText": "",
		"rawData": {
			"organisasjonsnummer": "919697199",
			"navn": "APPFARM AS",
			"organisasjonsform": {
				"kode": "AS",
				"beskrivelse": "Aksjeselskap",
				"_links": {
					"self": {
						"href": "https://data.brreg.no/enhetsregisteret/api/organisasjonsformer/AS"
					}
				}
			},
			"registreringsdatoEnhetsregisteret": "2017-10-10",
			"registrertIMvaregisteret": true,
			"naeringskode1": {
				"beskrivelse": "Programmeringstjenester",
				"kode": "62.010"
			},
			"antallAnsatte": 35,
			"forretningsadresse": {
				"land": "Norge",
				"landkode": "NO",
				"postnummer": "0164",
				"poststed": "OSLO",
				"adresse": [
					"Universitetsgata 2"
				],
				"kommune": "OSLO",
				"kommunenummer": "0301"
			},
			"stiftelsesdato": "2017-09-26",
			"institusjonellSektorkode": {
				"kode": "2100",
				"beskrivelse": "Private aksjeselskaper mv."
			},
			"registrertIForetaksregisteret": true,
			"registrertIStiftelsesregisteret": false,
			"registrertIFrivillighetsregisteret": false,
			"sisteInnsendteAarsregnskap": "2021",
			"konkurs": false,
			"underAvvikling": false,
			"underTvangsavviklingEllerTvangsopplosning": false,
			"maalform": "Bokmål",
			"_links": {
				"self": {
					"href": "https://data.brreg.no/enhetsregisteret/api/enheter/919697199"
				}
			}
		}
	}
}

In my example above, I would be able to map everything within rawData, such as “organisasjonsnummer”, and “navn”, but not the status code as that is not a part of the response data.

If you still want to map the response code, you’d have to use the Result Parser to return the response code, e.g. return {responseCode}. You may then map responseCode to a property. However, endpoints seldom return different successful response codes, so mapping this response would not really make sense.

2 Likes