diff --git a/packages/insomnia-app/app/common/import.js b/packages/insomnia-app/app/common/import.js index c9608fc33..bdd35d08b 100644 --- a/packages/insomnia-app/app/common/import.js +++ b/packages/insomnia-app/app/common/import.js @@ -179,7 +179,23 @@ export async function importRaw( continue; } - const existingDoc = await model.getById(resource._id); + // Try adding Content-Type JSON if no Content-Type exists + if ( + model.type === models.request.type && + resource.body && + typeof resource.body.text === 'string' && + Array.isArray(resource.headers) && + !resource.headers.find(h => h.name.toLowerCase() === 'content-type') + ) { + try { + JSON.parse(resource.body.text); + resource.headers.push({ name: 'Content-Type', value: 'application/json' }); + } catch (err) { + // Not JSON + } + } + + const existingDoc = await db.get(model.type, resource._id); let newDoc: BaseModel; if (existingDoc) { newDoc = await db.docUpdate(existingDoc, resource);